public Result Execute(string userIdString, string userPassword) { long userId = 0; try { userId = long.Parse(userIdString); } catch { return(Result.ERROR_USER_NOT_EXISTS); } return(_accountStorage.Transaction(Result.ERROR_UNDEFINED, _ => { var user = _accountStorage.Find(userId, userPassword); if (user == null) { return Result.ERROR_USER_NOT_EXISTS; } _accountStorage.Delete(userId); _dreamsStorage.DeleteAllForUser(userId); return Result.SUCCESS; })); }
public async Task <Unit> Handle(Command cmd, CancellationToken cancellationToken) { var user = await _storage.GetUser(cmd.UserId); if (user == null) { return(new Unit()); } user.Delete(cmd.Feedback); await _storage.Save(user); await _emails.Send( EmailSettings.Admin, Sender.NoReply, EmailTemplate.AdminUserDeleted, new { feedback = cmd.Feedback, email = user.State.Email }); await _storage.Delete(user); await _portfolio.Delete(user.Id); return(new Unit()); }