public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Payment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentExists(Payment.ReceiptNo)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int id) { if (ParkingSlot.TimeOut != null) { TimeSpan?hours = ParkingSlot.TimeOut - ParkingSlot.TimeIn; var totalhours = hours.Value.TotalHours; decimal final = Convert.ToDecimal(totalhours) + 1; var getReceipt = (from h in _context.Payment join b in _context.ParkingSlot on h.ParkingID equals b.ParkingID where b.ParkingID == id select h.ReceiptNo).Sum(); int receipt = Convert.ToInt32(getReceipt); var getCustomer = (from z in _context.Payment join x in _context.ParkingSlot on z.ParkingID equals x.ParkingID select x.CustomerID).Sum(); if (final > 6) { final = 6; } var getPrice = (from p in _context.Pricing where (p.Period == final) select p.Price).Sum(); var getCustDiscount = (from e in _context.Customer join t in _context.PositionDiscount on e.Position equals t.Position where (e.CustomerID == getCustomer) select t.Price).Sum(); final = (1 - (Convert.ToDecimal(getCustDiscount))) * Convert.ToDecimal(getPrice); final = decimal.Round(final, 2, MidpointRounding.AwayFromZero); setTotal(final, getReceipt, totalhours); } if (!ModelState.IsValid) { return(Page()); } _context.Attach(ParkingSlot).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParkingSlotExists(ParkingSlot.ParkingID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }