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);
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ReservationBook reservationBook = db.ReservationBooks.Find(id);

            db.ReservationBooks.Remove(reservationBook);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
 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));
 }
예제 #4
0
        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));
        }
예제 #5
0
        // 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
            }));
        }
예제 #6
0
        // 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));
        }
예제 #7
0
 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());
     }
 }
예제 #8
0
        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);
        }
예제 #10
0
        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());
            }
        }