Beispiel #1
0
        public ActionResult CardPayment(HGSPaymentInDTO dto)
        {
            try
            {
                if (dto.Balance < 0)
                {
                    TempData["Error"] = "Girdiğiniz bilgileri kontrol ediniz.";
                    return(Redirect($"/Hgs/Detail/{dto.CardId}"));
                }

                var     customerId      = UserSession.Info.Id;
                HGSCard card            = _externalService.GetHGSCardById(dto.CardId, customerId);
                decimal customerBalance = _accountService.GetAccountBalance(dto.AccountId);

                if (customerBalance < dto.Balance)
                {
                    TempData["Error"] = "Hesabınızda yeterli bakiye yok.";
                    return(Redirect($"/Hgs/Detail/{dto.CardId}"));
                }

                dto.VehicleType = card.VehicleType;
                dto.CustomerId  = customerId;
                dto.CreateDate  = DateTime.Now;
                dto.PaymentType = 1;

                HGSPaymentResultDTO result = _externalService.HGSPayment(dto);
                if (result.IsSuccess)
                {
                    TempData["Success"] = result.ResponseMessage;
                    return(Redirect($"/Hgs/Index"));
                }
                else
                {
                    TempData["Error"] = "Girdiğiniz bilgileri kontrol ediniz.";
                    return(Redirect($"/Hgs/Detail/{dto.CardId}"));
                }
            }
            catch (Exception)
            {
                TempData["Error"] = "Girdiğiniz bilgileri kontrol ediniz.";
                return(Redirect($"/Hgs/Index"));
            }
        }