Hi, Perhaps someone can tell me why this would occur.
The CreatorUserId on Update is getting set as NULL, which previously wasn't the case. So I've put in a little bit of a workaround:
private async Task Update(CreateOrEditGroupDto input)
{
var group = await _groupRepository.FirstOrDefaultAsync((int)input.Id);
var x = ObjectMapper.Map(input, group);
// replace creatoruserid hack because it's gone missing
x.CreatorUserId = AbpSession.UserId;
await _groupRepository.UpdateAsync(x);
}
The Create works fine still.
So it's not critical as the workaround is in place, however, I was just wondering if someone had seen this before and perhaps let me know where I have borked it.
Thanks for looking
7 Answer(s)
-
0
Does CreateOrEditGroupDto have a CreatorUserId property that is null?
-
0
Here is the Dto:
As it's derived from FullAuditedEntityDto, shouldn't it include the populated property?
public class CreateOrEditGroupDto : FullAuditedEntityDto<int?> { [Required] public string Name { get; set; } public string Description { get; set; } //public Collection<ContactDto> Contacts { get; set; } }
public async Task<GetGroupForEditOutput> GetGroupForEdit(EntityDto input) { var group = await _groupRepository.FirstOrDefaultAsync(input.Id); var output = new GetGroupForEditOutput {Group = ObjectMapper.Map<CreateOrEditGroupDto>(group)}; return output; }
-
0
It is populated in output, but did you populate it in input?
Consider using a CreateOrEditGroupInput that does not inherit FullAuditedEntityDto.
-
0
If it doesn't inherit from FullAuditedEntityDto, then would it automatically add the CreatorUserId on save/update?
so, essentially what you are saying is that because CreatorUserId exists and is NULL, it's getting overwritten? and that if it doesn't exist in the "input" Dto, then the CreatorUserId will be populated on save?
-
0
Yes, yes, and yes.
-
0
Awesome, thanks! clarity makes sense
-
0
That's great :)