// 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(Category).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(Category.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()); } _context.Attach(Equipment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EquipmentExists(Equipment.ID)) { return(NotFound()); } else { throw; } } TempData["Referrer2"] = "Endret"; 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()); } _context.Equipments.Add(Equipment); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Equipment = await _context.Equipments.FindAsync(id); if (Equipment != null) { _context.Equipments.Remove(Equipment); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Booking = await _context.Bookings.FindAsync(id); if (Booking != null) { _context.Bookings.Remove(Booking); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Category = await _context.Categories.FindAsync(id); if (Category != null) { _context.Categories.Remove(Category); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { BookingList = await _context.Bookings .Where(b => b.EquipmentID == id) .Where(b => b.EndDate >= DateTime.Now) .OrderBy(b => b.StartDate) .ToListAsync(); if (Booking.StartDate > Booking.EndDate) { return(Page()); } if (BookingList != null) { foreach (Booking b in BookingList) { if (b.EquipmentID == Booking.EquipmentID) { if (((Booking.StartDate < b.StartDate) && (Booking.EndDate <= b.StartDate)) || ((Booking.StartDate >= b.EndDate) && (Booking.EndDate > b.EndDate))) { continue; } else { return(Page()); } } } } //var errors = ModelState.Values.SelectMany(v => v.Errors); //if (!ModelState.IsValid) //{ // return Page(); //} _context.Bookings.Add(Booking); await _context.SaveChangesAsync(); return(RedirectToPage("/UserView/Index")); }