public async Task <long> Insert(string contextUserEmail, UserInsertDto dto) { await ThrowIfNotInRole(contextUserEmail, UserRoleEnum.Admin); if (dto == null) { throw new ArgumentNullException(nameof(UserInsertDto)); } var entity = dto.ToEntity(); _context.Users.Add(entity); await _context.SaveChangesAsync(); return(entity.Id); }
public void ToEntity_UserInsertDto_To_User() { var userDto = new UserInsertDto { DisplayName = "Prince Solms", Email = "*****@*****.**", Role = Data.Entities.UserRoleEnum.Admin }; var user = userDto.ToEntity(); var propertyExceptions = new Dictionary <string, Func <bool> > { { nameof(User.Id), () => true }, { nameof(User.Password), () => true }, }; EnsureConversionThroughReflection(userDto, user, propertyExceptions); }