public ActionResult DeleteConfirmed(int id) { ReservationSlot reservationslot = db.ReservationSlots.Find(id); db.ReservationSlots.Remove(reservationslot); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(ReservationSlot reservationslot) { if (ModelState.IsValid) { db.Entry(reservationslot).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(reservationslot)); }
// // GET: /Reservation/Edit/5 public ActionResult Edit(int id = 0) { ReservationSlot reservationslot = db.ReservationSlots.Find(id); if (reservationslot == null) { return(HttpNotFound()); } return(View(reservationslot)); }
public ActionResult Create(ReservationSlot reservationslot) { if (ModelState.IsValid) { db.ReservationSlots.Add(reservationslot); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(reservationslot)); }
public async Task <IActionResult> AddReservationSlot([FromBody] ReservationSlot reservationSlot) { var freeSlots = _context.ReservationSlots.Where(x => x.ConferenceRoomNumber == reservationSlot.ConferenceRoomNumber).Select(x => x) .Where(x => (x.StartTime >= reservationSlot.EndTime) && (x.EndTime <= reservationSlot.StartTime)).Select(x => x) .ToList().Count(); if (freeSlots == 0) { return(NoContent()); } _context.ReservationSlots.Add(reservationSlot); await _context.SaveChangesAsync(); return(Ok(reservationSlot)); }
public async Task <IActionResult> EditReservationSlot(int id, [FromBody] ReservationSlot reservationSlot) { var data = await _context.ReservationSlots.FindAsync(id); if (data == null) { return(NoContent()); } data.ConferenceRoomName = reservationSlot.ConferenceRoomName; data.ConferenceRoomNumber = reservationSlot.ConferenceRoomNumber; data.StartTime = reservationSlot.StartTime; data.EndTime = reservationSlot.EndTime; _context.ReservationSlots.Update(data); await _context.SaveChangesAsync(); return(Ok(data)); }