public async Task <IActionResult> AfterGateway(HillaPayAfterGatewayModel model) { var controller = _configuration["ShowPaymentResult:Controller"]; var action = _configuration["ShowPaymentResult:Action"]; if (model.Status.status != 400) { return(RedirectToAction(action, controller, new Response <string> { IsSuccessful = false, Result = model.result_transaction_callback.transaction_id })); } else { var findPayment = await _paymentSrv.FindAsync(model.result_transaction_callback.transaction_id); if (!findPayment.IsSuccessful) { return(RedirectToAction(action, controller, new Response <string> { IsSuccessful = false, Result = model.result_transaction_callback.transaction_id })); } var verify = await _orderSrv.Verify(findPayment.Result, new object[1] { model.result_transaction_callback.rrn }); if (verify.IsSuccessful) { await _deliverySrv.Add(findPayment.Result.OrderId); } return(RedirectToAction(action, controller, new Response <string> { IsSuccessful = verify.IsSuccessful, Result = model.result_transaction_callback.transaction_id })); } }
public Delivery Add(Delivery delivery) { return(_deliveryService.Add(delivery)); }
public IActionResult Add(DeliveryDto delivery) { return(Ok(delveryService.Add(delivery))); }
public IActionResult SaveEntity(InvoiceViewModel invoiceVm, List <InvoiceDetailViewModel> invoiceDetailVms) { if (!ModelState.IsValid) { IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); return(new BadRequestObjectResult(allErrors)); } else { var userid = _generalFunctionController.Instance.getClaimType(User, CommonConstants.UserClaims.Key); var c = _customerService.GetBysId(userid); if (c.KeyId != 0) { //var book = _bookService.GetById() foreach (var item in invoiceDetailVms) { var book = _bookService.GetById(item.BookFK); if (item.Qty > book.Quantity) { return(new OkObjectResult("quantity")); } } if (invoiceVm.DeliAddress == "" || invoiceVm.DeliAddress == null) { invoiceVm.DeliAddress = c.UserBy.Address; } if (invoiceVm.DeliContactName == "" || invoiceVm.DeliContactName == null) { invoiceVm.DeliContactName = c.UserBy.FullName; } if (invoiceVm.DeliContactHotline == "" || invoiceVm.DeliContactHotline == null) { invoiceVm.DeliContactHotline = c.UserBy.PhoneNumber; } invoiceVm.CustomerFK = c.KeyId; _invoiceService.Add(invoiceVm); _invoiceService.Save(); var invoice = _invoiceService.GetLastest(); foreach (var item in invoiceDetailVms) { item.InvoiceFK = invoice; _invoiceDetailService.Add(item); var book = _bookService.GetById(item.BookFK); book.Quantity = book.Quantity - item.Qty; _bookService.Update(book); } var deli = invoiceDetailVms.GroupBy(x => x.MerchantFK).Select(x => new DeliveryViewModel() { InvoiceFK = invoice, DeliveryStatus = Const_DeliStatus.UnConfirmed, OrderPrice = x.Sum(y => y.SubTotal), ShipPrice = 25000, MerchantFK = x.Key, }).ToList(); foreach (var item in deli) { _deliveryService.Add(item); } _invoiceService.Save(); HttpContext.Session.Remove("CartSession"); return(new OkObjectResult("true")); } return(new OkObjectResult("customer")); } }