Ejemplo n.º 1
0
        public AccountDTO FindByPhoneNumber(string phoneNumber)
        {
            var account    = _context.Accounts.FirstOrDefault(x => x.PhoneNum == phoneNumber);
            var accountDTO = AccountMapper.toDTO(account);

            return(accountDTO);
        }
        /// <summary>
        /// Method creates new account with given parameters and saves data to storage.
        /// </summary>
        /// <param name="accountOwner">
        /// Account owner - required data to create account.
        /// </param>
        /// <param name="type">
        /// Account type - required data to create account.
        /// </param>
        /// <param name="creator">
        /// Account number generation strategy injected as method argument.
        /// </param>
        public void OpenAccount(string accountOwner, AccountType type, IAccountNumberCreateService creator)
        {
            Account newAccount = AccountMapper.CreateAccount(type, creator.GenerateAccountNumber(AccountDTO.id), accountOwner, 0, 0);

            AccountDTO.id++;
            this.repository.Create(newAccount.ToAccountDTO());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 帐号业务
        /// </summary>
        public AccountBLL()
        {
            //RegistType();
            _userDAL = new AccountDataBridge();

            Mapper = AccountMapper.InitAllMapper();
        }
Ejemplo n.º 4
0
 public long?Save(AccountDto account)
 {
     if (account != null)
     {
         using (var context = new CashFlowContext())
         {
             if (account.Id.HasValue)
             {
                 context.Account.Update(AccountMapper.Map(account));
             }
             else
             {
                 Account accountMapped = AccountMapper.Map(account);
                 context.Account.Add(accountMapped);
                 account.Id = accountMapped.Id;
                 AccountBalance accountBalance = new AccountBalance();
                 accountBalance.AccountId = account.Id.Value;
                 accountBalance.Balance   = 0;
                 accountBalance.StartDate = DateTime.Now;
                 context.AccountBalance.Add(accountBalance);
             }
             context.SaveChanges();
         }
         return(account.Id);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 5
0
        public void DepositAccount(BankAccount account, decimal deposit)
        {
            account.Deposit(deposit);
            BankAccountDTO accToUpdate = AccountMapper.AccountToDTO(account);

            _repository.UpdateAccount(accToUpdate);
        }
Ejemplo n.º 6
0
        public void WithdrawAccount(BankAccount account, decimal withdraw)
        {
            account.Withdraw(withdraw);
            BankAccountDTO accToUpdate = AccountMapper.AccountToDTO(account);

            _repository.UpdateAccount(accToUpdate);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Author: Suman Basyal
        /// </summary>
        /// <param name="login"></param>
        /// <returns></returns>
        public bool SaveUserDetails(Login login)
        {
            var  entityUser = AccountMapper.ConvertToEntity(login);
            bool result     = _accountService.SaveUserDetails(entityUser);

            return(result);
        }
Ejemplo n.º 8
0
        public IEnumerable <Login> GetAllUser()
        {
            var list          = _accountService.GetAllUser().ToList();
            var convertedList = AccountMapper.ConvertToModel(list);

            return(convertedList);
        }
 public IEnumerable <Account> GetAllAccounts()
 {
     foreach (AccountDTO account in _repository.GetAllAccounts())
     {
         yield return(AccountMapper.MapAccountFromDTO(account));
     }
 }
        public void Deposit(int accountID, decimal amount)
        {
            foreach (AccountDTO accountDTO in _repository.GetAllAccounts())
            {
                Account account = AccountMapper.MapAccountFromDTO(accountDTO);
                if (account.AccountID == accountID)
                {
                    switch (account.Type)
                    {
                    case AccountType.BASE:
                        amount *= 1.05M;
                        break;

                    case AccountType.GOLD:
                        amount *= 1.10M;
                        break;

                    case AccountType.PLATINUM:
                        amount *= 1.25M;
                        break;
                    }

                    break;
                }
            }

            _repository.Deposit(accountID, amount);
        }
Ejemplo n.º 11
0
        public ActionResult _Edit(AccountEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }

            var account = AccountBL.Get(model.ID, base._DB);

            if (account.Password != model.ExPassword)
            {
                throw new BusinessException("Eski şifrenizi kontrol ederek tekrar deneyiniz.");
            }

            var mapper = new AccountMapper();

            var accountDTO = mapper.MapToDTO(model);

            AccountBL.Update(accountDTO.ID, accountDTO, base._DB);

            return(new ContentResult()
            {
                Content = "OK"
            });
        }
Ejemplo n.º 12
0
        public ActionResult <List <Account> > Get()
        {
            var accounts       = _accountService.Get();
            var accountsMapped = AccountMapper.DomainToSDK(accounts);

            return(accountsMapped);
        }
Ejemplo n.º 13
0
        public static void Main(string[] args)
        {
            IAccountService             service = Resolver.Get <IAccountService>();
            IAccountNumberCreateService creator = Resolver.Get <IAccountNumberCreateService>();

            service.OpenAccount("Base acc owner 1", AccountType.Base, creator);
            service.OpenAccount("Silver acc owner 2", AccountType.Silver, creator);
            service.OpenAccount("Gold acc owner 3", AccountType.Gold, creator);
            service.OpenAccount("Platinum acc owner 4", AccountType.Platinum, creator);

            var creditNumbers = service.GetAllAccounts().Select(acc => acc.AccountNumber).ToArray();

            foreach (var t in creditNumbers)
            {
                service.DepositAccount(t, 100);
            }

            foreach (var item in service.GetAllAccounts())
            {
                Console.WriteLine(item);
                Console.WriteLine();
            }

            foreach (var t in creditNumbers)
            {
                service.WithdrawAccount(t, 10);
            }

            foreach (var item in service.GetAllAccounts())
            {
                Console.WriteLine(item);
                Console.WriteLine();
                var qwe = AccountMapper.ConvertToDTO(item);
            }
        }
Ejemplo n.º 14
0
        private DbAccount ToDbAccount(DTOAccount item)
        {
            var account = _bankContext.Accounts.Find(item.Id) ?? throw new InvalidOperationException("Account not found, incorrect id!");
            var holder  = _bankContext.Holders.Find(item.Holder.Id) ?? throw new InvalidOperationException("Holder not found, incorrect id!");

            return(AccountMapper.UpdateDbAccount(item, account, holder));
        }
Ejemplo n.º 15
0
        public static AccountDTO Get(int id, MataDBEntities db)
        {
            var account = db.Account.Single(q => q.ID == id);

            var mapper = new AccountMapper();

            return(mapper.MapToDTO(account));
        }
Ejemplo n.º 16
0
        public static AccountDTO Get(string email, string password, MataDBEntities db)
        {
            var account = db.Account.Single(q => q.Email == email && q.Password == password);

            var mapper = new AccountMapper();

            return(mapper.MapToDTO(account));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Opens new account with given information
        /// </summary>
        /// <param name="accountOwner">The owner of the account</param>
        /// <param name="accountType">The account type</param>
        /// <param name="numberCreateService">Service for creating unique account number</param>
        public void OpenAccount(string accountOwner, Interface.Entities.AccountType accountType, IAccountNumberCreateService numberCreateService)
        {
            string accountNumber = numberCreateService.GetNumber();

            Interface.Entities.Account account = new Interface.Entities.Account(accountNumber, accountOwner, accountType);

            _repository.OpenAccount(AccountMapper.MapToData(account));
        }
Ejemplo n.º 18
0
        public static int Create(AccountDTO account, JewelleryDBEntities db)
        {
            var newAccount = AccountMapper.MapToEntity(account);

            db.Account.Add(newAccount);
            db.SaveChanges();

            return(newAccount.Id);
        }
Ejemplo n.º 19
0
        public IEnumerable <BankAccount> GetAllAccounts()
        {
            var accounts = _repository.GetAll();

            foreach (var acc in accounts)
            {
                yield return(AccountMapper.DTOToAccount(acc));
            }
        }
Ejemplo n.º 20
0
        public bool CreateUserAndAccount(RegisterModel model, out string result)
        {
            result = Messanger.Get(EMessages.CannotCreateUser);
            var account       = new Account();
            var accountMapper = new AccountMapper();

            accountMapper.Map(model, account);
            return(_accountFacade.SaveOrUpdate(account));
        }
 public AccountHandler(IAccountRepository accountRepository, IUserRepository userRepository)
 {
     _accountRepository                     = accountRepository;
     _userRepository                        = userRepository;
     _mapper                                = new AccountMapper();
     _createAccountCommandValidator         = new CreateAccountCommandValidator();
     _addUserToAccountCommandValidator      = new AddUserToAccountCommandValidator();
     _removeUserFromAccountCommandValidator = new RemoveUserFromAccountCommandValidator();
 }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            Employee      emp     = new EmployeeMapper().Get("1037");
            AccountMapper am      = new AccountMapper();
            Account       account = new Account(emp, am.GetAccounts());

            am.Insert(account);
            Console.ReadLine();
        }
Ejemplo n.º 23
0
        public IActionResult Delete(
            [FromHeader(Name = AuthProperties.HEADER_AUTH_ID)] string userId,
            [FromHeader(Name = AuthProperties.HEADER_AUTH_PASSOWRD)] string userPassword)
        {
            var serviceResult = _deleteAccountUseCase.Execute(userId, userPassword);
            var response      = AccountMapper.Map(serviceResult);

            return(new JsonResult(response));
        }
Ejemplo n.º 24
0
        public IActionResult SignIn(
            string email,
            string password)
        {
            var serviceResult = _signInUseCase.Execute(email, password);
            var response      = AccountMapper.Map(serviceResult);

            return(new JsonResult(response));
        }
Ejemplo n.º 25
0
        public static bool UpdatePWD(string username, string password)
        {
            AccountMapper account = new AccountMapper();

            account.Username = username;
            account.Password = password;

            Global.db.Updateable(account).UpdateColumns(x => new { x.Password, x.Username }).WhereColumns(x => new { x.Username }).ExecuteCommand();
            return(true);
        }
Ejemplo n.º 26
0
        public ActionResult _Edit(int id)
        {
            var accountDTO = AccountBL.Get(id, base._DB);

            var mapper = new AccountMapper();

            var model = mapper.MapToViewModel(accountDTO);

            return(PartialView(model));
        }
        public void Save()
        {
            List <Account> resList = new List <Account>(_accounts.Count);

            foreach (var account in _accounts)
            {
                resList.Add(AccountMapper.FromBllModel(account));
            }
            _storage.Load(resList);
        }
        public void Load()
        {
            var accounts = _storage.Read();

            _accounts.Clear();
            foreach (var account in accounts)
            {
                _accounts.Add(AccountMapper.ToBllModel(account));
            }
        }
Ejemplo n.º 29
0
    // private readonly TransactionMapper _transactionMapper;

    public MyDataQueriesRepository(IHolefeederContext context, AccountMapper accountMapper
                                   // CategoryMapper categoryMapper, CashflowMapper cashflowMapper, TransactionMapper transactionMapper
                                   )
    {
        _context       = context;
        _accountMapper = accountMapper;
        // _categoryMapper = categoryMapper;
        // _cashflowMapper = cashflowMapper;
        // _transactionMapper = transactionMapper;
    }
Ejemplo n.º 30
0
        public IActionResult SignUp(
            string email,
            string password,
            [FromQuery(Name = "name")] string name)
        {
            var serviceResult = _signUpUseCase.Execute(email, password, name);
            var response      = AccountMapper.Map(serviceResult);

            return(new JsonResult(response));
        }