Beispiel #1
0
        public ActionResult RemoveReservation(ReservationForChange reservForRemote)
        {
            int rId = int.Parse(reservForRemote.reservation);

            IQueryable <Reservation> reservations = db.Reservation.Where(r => r.ReservationId.Equals(rId));

            Reservation reserv = new Reservation();

            foreach (Reservation r in reservations)
            {
                reserv = r;
            }

            db.RemoveReservation(reserv);

            ReservationManager reservManager = new ReservationManager(reserv.StartDate);

            if (reservForRemote.view == 0)
            {
                ViewBag.id = "td";

                ViewBag.Auditoriums = db.Auditorium;
            }
            else if (reservForRemote.view == 1)
            {
                IQueryable <Auditorium> auditorium = db.Auditorium.Where(auditor => auditor.AuditoriumId.Equals(reserv.TargetAuditorium));

                foreach (Auditorium a in auditorium)
                {
                    reservManager.Table = new List <List <TD> >();

                    reservManager.Table = reservManager.GetDayRoomReservation(reserv.StartDate, a.AuditoriumName);

                    ViewBag.id = "td-day";

                    ViewBag.Room = a.AuditoriumName;

                    ViewBag.Date = reserv.StartDate;

                    ViewBag.Auditoriums = db.Auditorium.Where(auditor => auditor.AuditoriumName.Equals(a.AuditoriumName));
                }
            }
            else if (reservForRemote.view == 2)
            {
                IQueryable <Auditorium> auditorium = db.Auditorium.Where(auditor => auditor.AuditoriumId.Equals(reserv.TargetAuditorium));

                foreach (Auditorium a in auditorium)
                {
                    reservManager.Table = new List <List <TD> >();

                    reservManager.Table = reservManager.GetWeekReservation(reserv.StartDate, a.AuditoriumName);

                    ViewBag.id = "td";

                    ViewBag.week = reservManager.GetDays(reserv.StartDate);
                }
            }

            return(PartialView("Table", reservManager));
        }
Beispiel #2
0
        public ActionResult ChangeReservation(ReservationForChange newReservation)
        {
            Reservation reservation = db.Reservation.Where(res => res.ReservationId.Equals(newReservation.id)).First();

            reservation.Purpose = newReservation.purpose;

            db.SaveChanges();

            ReservationManager reservManager = new ReservationManager(reservation.StartDate);

            if (newReservation.view == 0)
            {
                ViewBag.id = "td";

                ViewBag.Auditoriums = db.Auditorium;
            }
            else if (newReservation.view == 1)
            {
                reservManager.Table = new List <List <TD> >();

                ViewBag.Room = reservation.Auditorium.AuditoriumName;

                ViewBag.Date = reservation.StartDate;

                reservManager.Table = reservManager.GetDayRoomReservation(reservation.StartDate, reservation.Auditorium.AuditoriumName);

                ViewBag.Auditoriums = reservation.Auditorium;

                ViewBag.id = "td-day";
            }
            else if (newReservation.view == 2)
            {
                reservManager.Table = new List <List <TD> >();

                ViewBag.id = "td";

                ViewBag.week = reservManager.GetDays(reservation.StartDate);

                reservManager.Table = reservManager.GetWeekReservation(reservation.StartDate, reservation.Auditorium.AuditoriumName);
            }

            return(PartialView("Table", reservManager));
        }