Example #1
0
 public async Task <ActionResult> AddReservation(ReservationViewModel viewModel)
 {
     if (viewModel.RoomId == null)
     {
         return(RedirectToAction("ShowInfo"));
     }
     if (new Time(viewModel.Start, viewModel.End).Check())
     {
         if (await rep.AddReservationAsync(viewModel))
         {
             return(RedirectToAction("ShowInfo", new { id = viewModel.RoomId }));
         }
         return(RedirectToAction("Reservation", new { id = viewModel.RoomId }));
     }
     return(RedirectToAction("Reservation", new { id = viewModel.RoomId }));
 }
Example #2
0
        public async Task <ActionResult> AddReservation(int?id, TimeSpan start, TimeSpan end, string userName)
        {
            if (id == null)
            {
                return(RedirectToAction("ShowInfo"));
            }
            string res;

            if (new Time(start, end).Check())
            {
                res = await rep.AddReservationAsync(start, end, (int)id, userName);
            }
            else
            {
                return(RedirectToAction("Reservation", new { id = id, state = "incorrect date value" }));
            }
            return(RedirectToAction("ShowInfo", new { id = id, state = res }));
        }