public IActionResult AddDepositAction(CashDepositAddActionViewModel model)
 {
     if (ModelState.IsValid)
     {
         decimal before = model.CurrentAmount;
         decimal after  = 0.00m;
         if (model.isPayment)
         {
             after = before - model.Amount;
         }
         else
         {
             after = before + model.Amount;
         }
         CashDepositAction action = new CashDepositAction
         {
             Id                 = Guid.NewGuid(),
             isPayment          = model.isPayment,
             Amount             = model.Amount,
             InvoiceNo          = model.InvoiceNo,
             ActionDate         = model.ActionDate,
             AmountBeforeAction = before,
             AmountAfterAction  = after,
             CashDepositId      = model.DepositId,
             Description        = model.Description
         };
         CashDeposit deposit = _cashDepositsRepository.GetCashDeposit(model.DepositId);
         deposit.CurrentAmount = after;
         _cashDepositsRepository.Update(deposit);
         _cashDepositActionsRepository.Add(action);
         return(RedirectToAction("DepositDetails", new { id = model.DepositId }));
     }
     return(RedirectToAction("Index"));
 }
Пример #2
0
        public void BtnMakeDeposit_Click(Label labelNotification, GuyNameEnum guyName, int amountDeposit)
        {
            ICommand    makeDepositCommand = _commandInvoker.GetCommand(ActionCommandEnum.DepositMoneyInGuyPocket);
            CashDeposit deposit            = new CashDeposit()
            {
                GuyName = guyName, CashAmount = amountDeposit
            };
            var notification = makeDepositCommand.Execute(deposit);

            labelNotification.Content    = notification.Description;
            labelNotification.Foreground = NotificationColors.GetBrushColor(notification.Code);
        }
        public ViewResult DepositDetails(Guid id)
        {
            CashDeposit deposit = _cashDepositsRepository.GetCashDeposit(id);
            List <CashDepositAction> actions = _cashDepositActionsRepository.GetActionsForDeposit(id).ToList();
            var model = new CashDepositDetailsViewModel
            {
                Id             = deposit.Id,
                CurrentAmount  = deposit.CurrentAmount,
                Description    = deposit.Description,
                Name           = deposit.Name,
                DepositActions = actions
            };

            return(View(model));
        }
Пример #4
0
        public Notification Execute(object obj = null)
        {
            var         notification         = new Notification();
            CashDeposit cashDeposit          = (CashDeposit)obj;
            var         allGuysInTheStadium  = _dogRacePalaceStadium.GetAllGuysInTheStadium();
            var         selectedGuyInStadium = allGuysInTheStadium.Where(a => a.Name == cashDeposit.GuyName).FirstOrDefault();

            if (selectedGuyInStadium != null)
            {
                selectedGuyInStadium.SetDeposit(cashDeposit.CashAmount);
                var cashBalance = selectedGuyInStadium.GetMoneyBalance();
                notification.Code        = NotificationEnum.Ok;
                notification.Description = AllNotifications.CashDepositOk(cashDeposit.GuyName.ToString(), (int)cashDeposit.CashAmount, (int)cashBalance);
                notification.Items       = allGuysInTheStadium.Count();
            }
            else
            {
                notification.Code        = NotificationEnum.Warning;
                notification.Description = AllNotifications.NoGuyAddedToTheStadiumWarning();
                notification.Items       = allGuysInTheStadium.Count();
            }
            return(notification);
        }