public void Register(int tenantId, int operatorId, User user) { foreach (var account in user.Accounts) { account.CreatedBy = operatorId; account.CreatedTime = DateTime.Now; account.UpdatedBy = operatorId; account.UpdatedTime = DateTime.Now; _accountDao.CreateAccount(account.ToDataObject()); } }
public Result <string, Account> AddNew(long accountTypeId, long providerId, string name, string number) { try { var accountHolder = _accountDao.GetAccount(accountTypeId, providerId, number); if (accountHolder != null) { return(Result <string, Account> .ForFailure("Looks like the account already exists")); } var id = _accountDao.CreateAccount(accountTypeId, providerId, name, number); var createdAccount = _accountDao.GetById(id); return(Result <string, Account> .ForSuccess(createdAccount)); } catch (Exception ex) { _logger.LogError("Can't create a new account: ", ex); return(Result <string, Account> .ForFailure("Can't create new account")); } }
public void CreateAccount_ShouldNot_Create_IfAccountExists() { using (var context = new PulsePiDBContext(GetTestOptions())) { context.Database.EnsureDeleted(); var createAccountDao = new AccountDao(context); var acc = new Account() { username = "******", password = "******" }; context.Add(acc); context.SaveChanges(); var response = createAccountDao.CreateAccount(acc); Assert.True(response.Exception.InnerException.Message.Equals("Account already exists")); Assert.True(response.IsFaulted); } }
/// <summary> /// Add new user into database /// </summary> /// <param name="user"></param> public void CreateAccount(User user) { accountDao.CreateAccount(user); }