public ActionResult CheckOut([FromQuery] int bookingId) { Bookings booking = _bookingService.CheckoutSlot(bookingId, out var rs); if (rs) { //Return deposit back to customer List <Transactions> depositTransactions = _paymentService.GetDepositTransactionsByBooking(bookingId); depositTransactions.ForEach(transaction => _paymentService.ReturnDeposit(transaction.Id)); //Get total money decimal totalPrice = booking.BookingServices .Select(service => service.Service) .Select(barberService => barberService.Price) .Sum() .GetValueOrDefault(); //Create payment transaction _paymentService.ForcePay( booking.CustomerId, booking.BarberId, booking.CustomerPaymentType, totalPrice, bookingId, TransactionConstants.TransactionDetail.PaidTransaction); return(new JsonResult("Checked out successfully") { StatusCode = StatusCodes.Status200OK }); } return(new JsonResult("Fail to checkout") { StatusCode = StatusCodes.Status404NotFound }); }
public ActionResult ReturnDeposit(int transactionId) { bool result = _paymentMethodService.ReturnDeposit(transactionId); if (!result) { return(new JsonResult(PaymentDescription.NotSuccess_VN) { StatusCode = StatusCodes.Status409Conflict }); } return(new JsonResult(null) { StatusCode = StatusCodes.Status200OK }); }