// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Car).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarExists(Car.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var Car = await _context.Car.Where(c => c.Id == CarBookingz.CarId).SingleOrDefaultAsync(); CarBookingz.TotalPrice = Car.DailyRate * ((CarBookingz.EndDate - CarBookingz.StartDate).Days + 1); CarBookingz.CreatedDate = DateTime.Now.Date; _context.Attach(CarBookingz).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarBookingzExists(CarBookingz.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }