public UserType SaveUser(UserType user) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entity = _userFactory.CreateUserEntity(user); entity.IsNew = entity.UserLogin.IsNew = (entity.UserId < 1); if (!adapter.SaveEntity(entity, true, true)) { throw new PersistenceFailureException(); } user.Id = entity.UserId; return(user); } }
public async Task ProcessRequest(RegisterRequest req, Connection conn, IList <IActionBag> actionBags) { if (await isValid(req, conn) == false) { return; } var newUser = _userFactory.CreateUserEntity(req); _userRepository.AddUser(newUser); await _userRepository.UnitOfWork.SaveChangesAsync(); conn.Send(new RegisterResponse(RegisterResult.Success, req)); Log.Information("Success register: {@UserEntity}", newUser.ToString()); await base.Handle(req, actionBags) .ConfigureAwait(false); }