public ActionResult Transfer(TrensferFrom trensferFrom)
        {
            if (TransactionCustomer == null)
            {
                TempData["error"] = "Client inconnu";
                return(RedirectToAction("Index", "Home"));
            }
            var customer = customerRepo.GetCustomerByID(TransactionCustomer.ID);

            if (ModelState.IsValid)
            {
                var sourceAccount = accountRepo.GetAccountByID(trensferFrom.SourceAccount);
                ValideTrensfer(trensferFrom, customer, sourceAccount);
                if (ModelState.IsValid)
                {
                    var accounts             = accountRepo.GetAccounts();
                    var destinationAccount   = accounts.FirstOrDefault(account => account.IBAN == trensferFrom.IBAN);
                    var sourceAtaTransaction = new AccountToAcountTransaction
                    {
                        Account         = sourceAccount,
                        Source          = sourceAccount,
                        Destination     = destinationAccount,
                        Date            = DateTime.Now,
                        Amount          = trensferFrom.Amount,
                        TransactionType = TransactionType.DEBIT,
                        Title           = trensferFrom.Label + " - " + trensferFrom.DestinationFullName
                    };
                    transactionRepo.InsertTransaction(sourceAtaTransaction);
                    sourceAccount.Debit(trensferFrom.Amount);
                    if (destinationAccount != null)
                    {
                        var destinationAtaTransaction = new AccountToAcountTransaction
                        {
                            Account         = destinationAccount,
                            Date            = DateTime.Now,
                            Amount          = trensferFrom.Amount,
                            TransactionType = TransactionType.CREDIT,
                            Title           = trensferFrom.Label + " - " + trensferFrom.DestinationFullName
                        };
                        transactionRepo.InsertTransaction(destinationAtaTransaction);
                        destinationAccount.Credit(trensferFrom.Amount);
                    }
                    TempData["notice"] = "virement enregistré";
                    accountRepo.Save();
                    return(RedirectToAction("Index", "Customer"));
                }
            }
            return(View(getSelectableAccounts(customer)));
        }
 public ActionResult PrintRIB()
 {
     if (RIBCustomer == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(View(accountRepo.GetAccounts().Where(a => a.Owner_ID == RIBCustomer.ID).ToList()));
 }
 private void validCreateAccount(AddAccountForm form)
 {
     try
     {
         accountRepo.GetAccounts().First(c => c.IBAN == form.IBAN);
         ModelState.AddModelError("IBAN", "IBAN déja attribué");
     }
     catch (Exception) { }
 }
示例#4
0
        public IEnumerable <Account> GetAccount()
        {
            IEnumerable <Account> accounts = _accountRepo.GetAccounts();

            if (accounts != null)
            {
                _logger.LogInformation("Getting all accounts.");
                return(accounts.ToList());
            }
            _logger.LogWarning("Attempted to get accounts but no accounts were available.");
            return(null);
        }
示例#5
0
        // GET: Account
        public ActionResult Index()
        {
            IEnumerable <Account>          accounts          = _accountRepo.GetAccounts();
            IEnumerable <AccountViewModel> accountViewModels = accounts.Select(x => new AccountViewModel
            {
                Id        = x.Id,
                Username  = x.Username,
                FirstName = x.FirstName,
                LastName  = x.LastName
            });

            return(View(accountViewModels));
        }
示例#6
0
        public ActionResult CompletedOrders(int id)
        {
            IEnumerable <Account>    accounts          = _accountRepo.GetAccounts();
            Dictionary <int, string> accountDictionary = Dictionary.AccountDictionary(accounts);
            IEnumerable <UserOrder>  orders            = _orderRepo.GetOrdersByStoreID(id);
            IEnumerable <CompletedOrdersViewModel> completedOrdersViewModels = orders.Select(x => new CompletedOrdersViewModel
            {
                FullName      = accountDictionary[x.UserId],
                OrderDateTime = DateTime.Now,
                TotalCost     = x.TotalCost,
                OrderContent  = Utilities.DeserializeFromXMLString(x.OrderContent)
            });

            ViewData["StoreName"] = Dictionary.StoreDictionary()[id];

            return(View(completedOrdersViewModels));
        }
        public List <Account> GetAccounts()
        {
            var items = _accRepo.GetAccounts();

            return(items.TransformAccInfo());
        }
 /// <summary>
 /// Gets all accounts saved on the system
 /// </summary>
 /// <returns>A list of all accounts saved on the system</returns>
 public IEnumerable <Account> GetAccounts()
 {
     return(accountRepo.GetAccounts());
 }
示例#9
0
        public ActionResult <IEnumerable <AccountReadDto> > GetAccounts()
        {
            var accounts = _repository.GetAccounts();

            return(Ok(_mapper.Map <IEnumerable <AccountReadDto> >(accounts)));
        }