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() { if (!ModelState.IsValid) { return(Page()); } _context.PositionDiscount.Add(PositionDiscount); await _context.SaveChangesAsync(); 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")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Pricing = await _context.Pricing.FindAsync(id); if (Pricing != null) { _context.Pricing.Remove(Pricing); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Customer = await _context.Customer.FindAsync(id); if (Customer != null) { _context.Customer.Remove(Customer); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Admin = await _context.Admin.FindAsync(id); if (Admin != null) { _context.Admin.Remove(Admin); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } PositionDiscount = await _context.PositionDiscount.FindAsync(id); if (PositionDiscount != null) { _context.PositionDiscount.Remove(PositionDiscount); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (!ModelState.IsValid) { return(Page()); } var customerToUpdate = await _context.Customer.FindAsync(id); if (await TryUpdateModelAsync <Customer>( customerToUpdate, "Customer", // Prefix for form value. c => c.CustomerID, c => c.FirstName, c => c.LastName, c => c.PhoneNo, c => c.Email, c => c.Position)) { await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } // Select DepartmentID if TryUpdateModelAsync fails. PositionDropdown(_context, customerToUpdate.Position); return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var emptyCustomer = new Customer(); if (await TryUpdateModelAsync <Customer>( emptyCustomer, "Customer", // Prefix for form value. c => c.CustomerID, c => c.FirstName, c => c.LastName, c => c.PhoneNo, c => c.Email, c => c.Position)) { _context.Customer.Add(emptyCustomer); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } // Select DepartmentID if TryUpdateModelAsync fails. PositionDropdown(_context, emptyCustomer.PositionDiscount); return(Page()); }