public Result CreateAccount(UserAccountCreationInfo userInfo, out User user) { // Validate dto ValidationHelper.ValidateModel(userInfo); // Create user object user = Mapper.Map <User>(userInfo); user.PasswordHash = PasswordHashHelper.CreateHash(userInfo.Password); user.LastLoginDate = DateTime.Now; // Validate user ValidationHelper.ValidateModel(user); // Other validations string email = user.Email; if (dataAccessor.Users.Any(other => email == other.Email)) { throw new ValidationException(MsgAccountWithEmailExists); } // Do save dataAccessor.Create(user); dataAccessor.SaveChanges(); return(Login(new LoginInfo { Email = userInfo.Email, Password = userInfo.Password })); }
public override void CreateRole(string roleName) { Role role = new Role { RoleName = roleName }; dataAccessor.Create(role); dataAccessor.SaveChanges(); }
public Task AddOrUpdate(PlayModel play) { return(Task.Factory.StartNew(() => { var playEntity = _mapper.Map <PlayEntity>(play); if (_plays.Keys.Contains(play.Id)) { _playAccessor.Update(playEntity); } else { _playAccessor.Create(playEntity); } _plays.AddOrUpdate(play); })); }
public Task AddOrUpdate(LinkedGameModel expansion) { return(Task.Factory.StartNew(() => { var linkedGameEntity = _mapper.Map <LinkedGameEntity>(expansion); if (_linkedGames.Keys.Contains(expansion.Id)) { _linkedGameAccessor.Update(linkedGameEntity); } else { _linkedGameAccessor.Create(linkedGameEntity); } _linkedGames.AddOrUpdate(expansion); })); }
public Task AddOrUpdate(GameModel game) { return(Task.Factory.StartNew(() => { var gameEntity = _mapper.Map <GameEntity>(game); if (_games.Keys.Contains(game.Id)) { _gameAccessor.Update(gameEntity); } else { _gameAccessor.Create(gameEntity); } _games.AddOrUpdate(game); })); }
public Task <OperationResult <int> > CreateAsync(TModel model) => Task.Run(() => _dataAccessor.Create(_queryProvider.Create(model)));