public async Task <IActionResult> Create(CreateDepositViewModel model)
        {
            if (ModelState.IsValid)
            {
                int depositId = await _depositService.Create(model);

                return(RedirectToAction(nameof(Details), new { depositId = depositId }));
            }

            return(View(model));
        }
Exemple #2
0
        public IActionResult Create(DepositModel model)
        {
            try
            {
                ViewBagData();

                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                model.EmployeeId      = GetEmployeeId().Result;
                model.CustomerId      = GetCustomerId(model.CustomerId);
                model.Reference       = _generator.DateCodeString() + _generator.RandomNumber(1111111, 7777777);
                model.TransactionCode = model.TransactionCode == (TransactionCode)1
                    ? TransactionCode.Deposit
                    : TransactionCode.Withdrawal;

                var request = _depositService.Create(model);
                if (request.Successful)
                {
                    return(RedirectToAction("History", "Savings", new { id = model.CustomerId }));
                }

                if (request.ResultType == ResultType.InsufficientBalance)
                {
                    TempData["Error"] = "Insufficient Balance";
                }

                if (request.ResultType == ResultType.PendingTransaction)
                {
                    TempData["Error"] = "This custormer has a pending transaction";
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message + " " + ex.InnerException);
            }

            return(View(model));
        }
Exemple #3
0
        public ActionResult Create(DepositForm depositForm)
        {
            if (!ModelState.IsValid)
            {
                return(View(depositForm));
            }

            var deposit = depositForm.ToDeposit();

            _depositService.Create(deposit);

            return(RedirectToAction("Index", new DepositListFiltersModel().GetRouteValues()).WithSuccess("Depósito Creado"));
        }
 private IActionResult ProcessSavings(DepositModel model)
 {
     try
     {
         if (model.CustomerId != null)
         {
             _depositService.Create(model);
         }
         return(Ok());
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message + " " + ex.InnerException);
     }
     return(Content("Internal server error please contact the system administrator"));
 }
 public async Task CreateDeposit(Deposit deposit)
 {
     await _depositService.Create(deposit);
 }