Thank you for the quick response.
Yes, the web project is working without any issues.
As for DbGeography, this is an Entity Framework spatial type. To use the DbGeography type, you must add a reference to the System.Data.Entity assembly and also add the System.Data.Spatial using statement.
Again, thank you in advance.
When adding either of the following to an entity breaks the Test project.
public virtual DbGeography Location { get; set; }
or
[Column(TypeName = "Money")] public decimal MonthlyFee { get; set; }
I can handle using a decimal field in place of Money. However, I don't know how to get around DbGeography. Here is the exception when running ANY test:
System.Collections.Generic.KeyNotFoundException was unhandled by user code
HResult=-2146232969
Message=The given key was not present in the dictionary.
Source=mscorlib
StackTrace:
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Effort.Provider.EffortProviderManifest.GetStoreType(TypeUsage edmType) at System.Data.Entity.ModelConfiguration.Edm.Services.StructuralTypeMappingGenerator.MapTableColumn(EdmProperty property, String columnName, Boolean isInstancePropertyOnDerivedType) at System.Data.Entity.ModelConfiguration.Edm.Services.PropertyMappingGenerator.Generate(EntityType entityType, IEnumerable
1 properties, EntitySetMapping entitySetMapping, MappingFragment entityTypeMappingFragment, IList1 propertyPath, Boolean createNewColumn) at System.Data.Entity.ModelConfiguration.Edm.Services.TableMappingGenerator.Generate(EntityType entityType, DbDatabaseMapping databaseMapping) at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.GenerateEntityTypes(DbDatabaseMapping databaseMapping) at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.Generate(EdmModel conceptualModel) at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo) at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) at System.Data.Entity.Internal.RetryLazy
2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at Abp.EntityFramework.AbpDbContext.Initialize()
at Castle.MicroKernel.LifecycleConcerns.InitializationConcern.Apply(ComponentModel model, Object component)
at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.ApplyConcerns(IEnumerable1 steps, Object instance) at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.ApplyCommissionConcerns(Object instance) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context) at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden) at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally) at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy) at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden) at Castle.MicroKernel.Handlers.ExtendedHandler.InvokeResolvePipeline(Int32 extensionIndex, ResolveInvocation invocation) at Castle.MicroKernel.Handlers.ExtendedHandler.<>c__DisplayClass6.<InvokeResolvePipeline>b__5() at Castle.MicroKernel.Handlers.ResolveInvocation.Proceed() at Castle.MicroKernel.Handlers.ComponentLifecycleExtension.Intercept(ResolveInvocation invocation) at Castle.MicroKernel.Handlers.ExtendedHandler.InvokeResolvePipeline(Int32 extensionIndex, ResolveInvocation invocation) at Castle.MicroKernel.Handlers.ExtendedHandler.Resolve(CreationContext context, Boolean instanceRequired) at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context) at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy) at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy) at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments) at Castle.Windsor.WindsorContainer.Resolve[T]() at Abp.Dependency.IocManager.Resolve[T]() at FourMartinis.TracZu.Tests.AppTestBase.UsingDbContext(Action
1 action) in D:\Documents\GitHub\TracZu\Tests\FourMartinis.TracZu.Tests\AppTestBase.cs:line 67
at FourMartinis.TracZu.Tests.AppTestBase..ctor() in D:\Documents\GitHub\TracZu\Tests\FourMartinis.TracZu.Tests\AppTestBase.cs:line 34
at FourMartinis.TracZu.Tests.Auditing.AuditLogAppService_Tests..ctor() in D:\Documents\GitHub\TracZu\Tests\FourMartinis.TracZu.Tests\Auditing\AuditLogAppService_Tests.cs:line 20
InnerException:
Thank you in advance.
Thank you for the quick response. I discovered my issue and wanted to share it here to make sure I am performing the update correctly by your standards.
I believe my issue was in my service method.
Orginal Update Method which was updated the CreatorUserId to NULL:
var group = input.MapTo<Group>();
await _groupRepository.UpdateAsync(group);
Corrected Update Method which now saves correctly:
var group = await _groupRepository.FirstOrDefaultAsync(g => g.Id == input.Id);
input.MapTo(group);
await _groupRepository.UpdateAsync(group);
When a record is created, the framework populates the CreationTime correctly and sets the CreatorUserId to the logged in user correctly. When the record is modified, the framework populates the LastModificationTime and LastModifierUserId correctly. However, it also makes the CreaterUserId null after the record is modified. Is this by design? If yes, is there a way to keep the CreatorUserId from getting cleared?
Any suggestions?
Hello, Thank you for the quick reply.
Yes, both methods are in the same class which implements from an interface. However, making CreateGroup virtual had no impact. Maybe you can see something I did wrong? FYI, I am using 1.3.0 from a fresh download.
Again, I appreciate any assistance.
IGroupAppService.cs
public interface IGroupAppService : IApplicationService
{
Task<PagedResultOutput<GroupListDto>> GetGroups(GetGroupsInput input);
Task CreateGroup(CreateGroupInput input);
Task<GroupEditDto> GetGroupForEdit(EntityRequestInput input);
Task UpdateGroup(GroupEditDto input);
Task DeleteGroup(EntityRequestInput input);
}
Here is the complete GroupAppService.cs
[AbpAuthorize(AppPermissions.Pages_Tenant_Account_Groups)]
public class GroupAppService : TracZuAppServiceBase, IGroupAppService
{
private readonly IRepository<Group, long> _groupRepository;
public GroupAppService(IRepository<Group, long> groupRepository)
{
_groupRepository = groupRepository;
}
public async Task<PagedResultOutput<GroupListDto>> GetGroups(GetGroupsInput input)
{
var query = _groupRepository
.GetAll()
.WhereIf(
!input.Filter.IsNullOrEmpty(),
g => g.Name.Contains(input.Filter) ||
g.Description.Contains(input.Filter)
);
var resultCount = await query.CountAsync();
var results = await query
.AsNoTracking()
.OrderBy(input.Sorting)
.PageBy(input)
.ToListAsync();
return new PagedResultOutput<GroupListDto>(resultCount, results.MapTo<List<GroupListDto>>());
}
[AbpAuthorize(AppPermissions.Pages_Tenant_Account_Groups_Create)]
public async Task CreateGroup(CreateGroupInput input)
{
var group = input.MapTo<Group>();
await _groupRepository.InsertAsync(group);
}
[AbpAuthorize(AppPermissions.Pages_Tenant_Account_Groups_Edit)]
public async Task<GroupEditDto> GetGroupForEdit(EntityRequestInput input)
{
var group = await _groupRepository.FirstOrDefaultAsync(g => g.Id == input.Id);
return group.MapTo<GroupEditDto>();
}
[AbpAuthorize(AppPermissions.Pages_Tenant_Account_Groups_Edit)]
public async Task UpdateGroup(GroupEditDto input)
{
var group = input.MapTo<Group>();
await _groupRepository.UpdateAsync(group);
}
[AbpAuthorize(AppPermissions.Pages_Tenant_Account_Groups_Delete)]
public async Task DeleteGroup(EntityRequestInput input)
{
await _groupRepository.DeleteAsync(input.Id);
}
}
I am calling the CreateGroup from the Angular application via the following controller:
(function () {
appModule.controller('tenant.views.groups.createModal', [
'$scope', '$modalInstance', 'abp.services.app.group',
function ($scope, $modalInstance, groupService) {
var vm = this;
vm.saving = false;
vm.group = {};
vm.save = function () {
vm.saving = true;
groupService.createGroup(vm.group)
.success(function () {
abp.notify.info(app.localize('SavedSuccessfully'));
$modalInstance.close();
}).finally(function () {
vm.saving = false;
});
}
vm.cancel = function () {
$modalInstance.dismiss();
}
}
]);
})();
I have the following method, which is NOT being included in the Audit Log when executed:
[AbpAuthorize(AppPermissions.Pages_Tenant_Account_Groups_Create)]
public async Task CreateGroup(CreateGroupInput input)
{
var group = input.MapTo<Group>();
await _groupRepository.InsertAsync(group);
}
However, this method is included in the Audit Log when executed:
[AbpAuthorize(AppPermissions.Pages_Tenant_Account_Groups_Edit)]
public async Task<GroupEditDto> GetGroupForEdit(EntityRequestInput input)
{
var group = await _groupRepository.FirstOrDefaultAsync(g => g.Id == input.Id);
return group.MapTo<GroupEditDto>();
}
Here are the Dto classes begin used:
[AutoMapTo(typeof(Group))]
public class CreateGroupInput: IInputDto
{
[Required]
[StringLength(Group.MaxNameLength)]
public string Name { get; set; }
[StringLength(Group.MaxDescriptionLength)]
public string Description { get; set; }
}
[AutoMap(typeof(Group))]
public class GroupEditDto : EntityDto, IDoubleWayDto
{
[Required]
[StringLength(Group.MaxNameLength)]
public string Name { get; set; }
[StringLength(Group.MaxDescriptionLength)]
public string Description { get; set; }
}
Does anyone know what I am missing?
Thank you in advance.