示例#1
0
 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"));
            }
        }
示例#3
0
        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);
            }
        }
示例#4
0
 /// <summary>
 /// Add new user into database
 /// </summary>
 /// <param name="user"></param>
 public void CreateAccount(User user)
 {
     accountDao.CreateAccount(user);
 }