public async Task <OperationStatus> GetReservationBook(int id, long startTime, long endTime) { ReservationBook rBook = await _calendarRepository.SingleAsync <ReservationBook>(r => r.ID == id, "CalendarBookAllocations"); TimePeriod timePeriod = new TimePeriod { unitsAsDays = true, startTime = startTime, endTime = endTime }; ReservationBookDTO rBookDTO = new ReservationBookDTO(rBook, timePeriod, true, false, false); OperationStatus ret; if (rBookDTO != null) { ret = new OperationStatus { Status = true, Data = rBookDTO }; } else { ret = new OperationStatus { Status = false, Message = "Not found" }; } return(ret); }
public ActionResult DeleteConfirmed(int id) { ReservationBook reservationBook = db.ReservationBooks.Find(id); db.ReservationBooks.Remove(reservationBook); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Description,StartTime,EndTime")] ReservationBook reservationBook) { if (ModelState.IsValid) { db.Entry(reservationBook).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(reservationBook)); }
public ActionResult Create([Bind(Include = "ID,Description,StartTime,EndTime")] ReservationBook reservationBook) { if (ModelState.IsValid) { db.ReservationBooks.Add(reservationBook); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(reservationBook)); }
// GET: Language/Edit/5 public ActionResult Edit(Guid id) { ReservationBook reservationBook = _dbContext.ReservationBooks.Where(c => c.ID == id).Include(c => c.BookItem).Include(c => c.User).First(); var bookItem = _dbContext.BookItems.ToList(); var users = _dbContext.Users.ToList(); ViewBag.BookItems = new MultiSelectList(bookItem, "ID", "ID"); ViewBag.Users = new MultiSelectList(users, "ID", "FullName"); return(View(new ReservationBookViewModel { ID = reservationBook.ID })); }
// GET: ReservationBook/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ReservationBook reservationBook = db.ReservationBooks.Find(id); if (reservationBook == null) { return(HttpNotFound()); } return(View(reservationBook)); }
public ActionResult DeleteReservationBook(Guid id) { try { ReservationBook reservationBook = new ReservationBook { ID = id }; _dbContext.ReservationBooks.Remove(reservationBook); _dbContext.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Edit(ReservationBookViewModel reservationBookViewModel) { try { BookItem bookItem = _dbContext.BookItems.Find(reservationBookViewModel.selectedBookItem); User user = _dbContext.Users.Find(reservationBookViewModel.selectedUser); ReservationBook reservationBook = new ReservationBook { ID = reservationBookViewModel.ID, BookItem = bookItem, User = user }; _dbContext.ReservationBooks.Update(reservationBook); _dbContext.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <OperationStatus> GetReservationBook(int id) { ReservationBook rBook = await _calendarRepository.SingleAsync <ReservationBook>(r => r.ID == id); ReservationBookDTO rBookDTO = new ReservationBookDTO(rBook, null, false, false, false); OperationStatus ret; if (rBookDTO != null) { ret = new OperationStatus { Status = true, Data = rBookDTO }; } else { ret = new OperationStatus { Status = false, Message = "Not found" }; } return(ret); }
public async Task <IActionResult> Create(ReservationBookViewModel reservationBookViewModel) { try { BookItem bookItem = _dbContext.BookItems.Find(reservationBookViewModel.selectedBookItem); User user = _dbContext.Users.Find(reservationBookViewModel.selectedUser); ReservationBook reservationBook = new ReservationBook { ID = reservationBookViewModel.ID, BookItem = bookItem, User = user }; _dbContext.ReservationBooks.Add(reservationBook); await _dbContext.SaveChangesAsync(); return(RedirectToPage("/Index")); } catch { return(View()); } }