コード例 #1
0
        public ActionResult RoomReservation(ROOM_RESERVATIONS model)
        {
            model.RoomCode = _roomId;
            var ReservationList = dbOperations.GetRoomReservation(model.RoomCode);

            TimeSpan beginDifference    = new TimeSpan();
            TimeSpan endDifference      = new TimeSpan();
            TimeSpan beginEndDifference = new TimeSpan();
            TimeSpan EndbeginDifference = new TimeSpan();
            TimeSpan zero             = new TimeSpan(0, 0, 0, 0);
            var      sequenceBeginEnd = model.EndDate - model.BeginDate;

            if (sequenceBeginEnd < zero)
            {
                return(RedirectToAction("WrongEndBeginDate"));
            }
            foreach (var reservation in ReservationList)
            {
                beginDifference    = reservation.BeginDate - model.BeginDate;
                endDifference      = reservation.EndDate - model.EndDate;
                beginEndDifference = reservation.BeginDate - model.EndDate;
                EndbeginDifference = reservation.EndDate - model.BeginDate;

                if ((beginEndDifference <= zero && endDifference >= zero) || (endDifference <= zero && EndbeginDifference >= zero) || (beginEndDifference <= zero && beginDifference >= zero))
                {
                    return(RedirectToAction("RoomIsReserved"));
                }
            }

            model.RoomCode   = _roomId;
            model.EmployeeId = GetLoggedUserId();
            DbOperations.AddRoomReservationToDb(model);
            return(RedirectToAction("RoomList"));
        }
コード例 #2
0
 public static void RemoveRoomReservationToDb(ROOM_RESERVATIONS model)
 {
     using (var context = new Contextt())
     {
         context.RoomReservationContext.Remove(model);
         context.SaveChanges();
     };
 }
コード例 #3
0
        public ROOM_RESERVATIONS GetRoomReservationByID(int id)
        {
            ROOM_RESERVATIONS reservations = new ROOM_RESERVATIONS();

            using (var context = new APSITestDbEntities1())
            {
                reservations = context.ROOM_RESERVATIONS.First(r => r.RoomResId == id);
            }
            return(reservations);
        }
コード例 #4
0
        public ActionResult DeleteRoomReservation(int id)
        {
            _roomReservation = dbOperations.GetRoomReservationByID(id);

            return(View(_roomReservation));
        }