Exemple #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));
        }
Exemple #2
0
        public ActionResult RoomDate(ReservationAuditoriumDay model)
        {
            string[] parse = model.date.Split(' ');

            string[] parts = parse[parse.Length - 1].Split('.');

            int year = int.Parse(parts[2]), month = int.Parse(parts[1]), day = int.Parse(parts[0]);

            DateTime date = new DateTime(year, month, day, 0, 0, 0);

            ReservationManager reservManager = new ReservationManager(date);

            if (model.auditorium != null)
            {
                reservManager.Table = new List <List <TD> >();

                reservManager.Table = reservManager.GetDayRoomReservation(date, model.auditorium);

                ViewBag.id = "td-day";

                ViewBag.Room = model.auditorium;

                ViewBag.Date = date;
            }
            else
            {
                ViewBag.id = "td";

                ViewBag.Auditoriums = db.Auditorium;
            }

            return(PartialView("Table", reservManager));
        }
Exemple #3
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));
        }
Exemple #4
0
        public ActionResult ShowRoom(string room)
        {
            if (Session["IsAuthenticated"] == null)
            {
                Session["IsAuthenticated"] = false;
            }

            DateTime date = DateTime.Now;

            ReservationManager reservManager = new ReservationManager(date);

            reservManager.Table = new List <List <TD> >();

            reservManager.Table = reservManager.GetDayRoomReservation(date, room);

            ViewBag.Date = date;

            ViewBag.Room = room;

            ViewBag.id = "td-day";

            return(View("Room", reservManager));
        }
Exemple #5
0
        // GET: Room
        public ActionResult Index(DateTime date, string room)
        {
            if (Session["IsAuthenticated"] == null)
            {
                Session["IsAuthenticated"] = false;
            }

            ReservationManager reservManager = new ReservationManager(date);

            reservManager.Table = new List <List <TD> >();

            reservManager.Table = reservManager.GetDayRoomReservation(date, room);

            ViewBag.Date = date;

            ViewBag.Room = room;

            ViewBag.Auditoriums = db.Auditorium.Where(auditor => auditor.AuditoriumName.Equals(room));

            ViewBag.id = "td-day";

            return(View("Room", reservManager));
        }
Exemple #6
0
        public int IsCanBlockOnPeriod(ReservationAuditoriumDay model)
        {
            int result = 1;

            string[] parts = model.date.Split('.');

            int year = int.Parse(parts[2]), month = int.Parse(parts[1]), day = int.Parse(parts[0]);

            DateTime date = new DateTime(year, month, day, DateTime.Now.Hour + 1, 0, 0);

            if (date < DateTime.Now)
            {
                return(2); //in the past
            }

            ReservationManager reservManager = new ReservationManager(date);

            reservManager.Table = new List <List <TD> >();

            if (model.period)
            {
                reservManager.Table = reservManager.GetDayRoomReservation(date, model.auditorium);
            }
            else
            {
                reservManager.Table = reservManager.GetWeekReservation(date, model.auditorium);
            }

            if (
                (from tr in reservManager.Table from td in tr where td.ReservationId > 0 select td).Any(
                    td => td.FinishDate > DateTime.Now || td.StartDate > DateTime.Now))
            {
                return(0); //reservation is exist
            }

            return(result);
        }
Exemple #7
0
        public ActionResult AddReservation(NewResevation newReservation)
        {
            Reservation reservation = new Reservation();

            string email = Session["UserEmail"].ToString();

            reservation.CreatedBy = db.User.Where(u => u.Email.Equals(email)).First().UserId;

            reservation.StartDate = new DateTime(newReservation.year, newReservation.month, newReservation.day, newReservation.hour, 0, 0);


            if (newReservation.finish_hour == 0)
            {
                reservation.FinishDate = new DateTime(newReservation.year, newReservation.month, newReservation.day, newReservation.hour + 1, 0, 0);
            }
            else
            {
                if (newReservation.view == 1)
                {
                    reservation.FinishDate = new DateTime(newReservation.year, newReservation.month, newReservation.day, newReservation.finish_hour, 0, 0);
                }
                else
                {
                    reservation.FinishDate =
                        GetLastDayWeek(new DateTime(newReservation.year, newReservation.month, newReservation.day,
                                                    newReservation.finish_hour, 0, 0));
                }
            }

            reservation.Type = newReservation.type;

            reservation.Purpose = newReservation.purpose;

            if (newReservation.auditorium == 0)
            {
                reservation.TargetAuditorium = db.Auditorium.Where(a => a.AuditoriumName.Equals(newReservation.auditorium_name)).First().AuditoriumId;

                newReservation.auditorium = reservation.TargetAuditorium;
            }
            else
            {
                reservation.TargetAuditorium = newReservation.auditorium;
            }

            db.AddReservation(reservation);

            ReservationManager reservManager = new ReservationManager(reservation.StartDate);

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

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

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

                    ViewBag.Room = a.AuditoriumName;

                    ViewBag.Date = reservation.StartDate;

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

                    ViewBag.Auditoriums = db.Auditorium.Where(auditor => auditor.AuditoriumName.Equals(a.AuditoriumName));

                    ViewBag.id = "td-day";
                }
            }
            else if (newReservation.view == 2)
            {
                IQueryable <Auditorium> auditorium = db.Auditorium.Where(auditor => auditor.AuditoriumId.Equals(newReservation.auditorium));

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

                    ViewBag.id = "td";

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

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

            return(PartialView("Table", reservManager));
        }
Exemple #8
0
        public ActionResult ChangeRoom(NewRoomModel room)
        {
            Auditorium changeAuditorium =
                db.Auditorium.Where(a => a.AuditoriumName.Equals(room.Name)).First();

            changeAuditorium.Capacity = room.Capacity;

            AdditionalEquipment wifi = db.AdditionalEquipment.Where(addeq => addeq.AdditionalEquipmentName.Equals("Wifi")).First();

            AdditionalEquipment monitor = db.AdditionalEquipment.Where(addeq => addeq.AdditionalEquipmentName.Equals("Монитор")).First();

            AdditionalEquipment projector = db.AdditionalEquipment.Where(addeq => addeq.AdditionalEquipmentName.Equals("Проектор")).First();

            AdditionalEquipment microphone = db.AdditionalEquipment.Where(addeq => addeq.AdditionalEquipmentName.Equals("Микрофон")).First();

            if (changeAuditorium.AdditionalEquipment.Contains(wifi))
            {
                if (room.Wifi == false)
                {
                    db.DeleteAuditoriumEquipment(changeAuditorium.AuditoriumId, wifi.AdditionalEquipmentId);
                }
            }
            else
            {
                if (room.Wifi == true)
                {
                    db.InsertAudEq(changeAuditorium.AuditoriumId, wifi.AdditionalEquipmentId);
                }
            }

            if (changeAuditorium.AdditionalEquipment.Contains(monitor))
            {
                if (room.Monitor == false)
                {
                    db.DeleteAuditoriumEquipment(changeAuditorium.AuditoriumId, monitor.AdditionalEquipmentId);
                }
            }
            else
            {
                if (room.Monitor == true)
                {
                    db.InsertAudEq(changeAuditorium.AuditoriumId, monitor.AdditionalEquipmentId);
                }
            }

            if (changeAuditorium.AdditionalEquipment.Contains(projector))
            {
                if (room.Projector == false)
                {
                    db.DeleteAuditoriumEquipment(changeAuditorium.AuditoriumId, projector.AdditionalEquipmentId);
                }
            }
            else
            {
                if (room.Projector == true)
                {
                    db.InsertAudEq(changeAuditorium.AuditoriumId, projector.AdditionalEquipmentId);
                }
            }

            if (changeAuditorium.AdditionalEquipment.Contains(microphone))
            {
                if (room.Microphone == false)
                {
                    db.DeleteAuditoriumEquipment(changeAuditorium.AuditoriumId, microphone.AdditionalEquipmentId);
                }
            }
            else
            {
                if (room.Microphone == true)
                {
                    db.InsertAudEq(changeAuditorium.AuditoriumId, microphone.AdditionalEquipmentId);
                }
            }

            db.SaveChanges();

            ViewBag.Room = room.Name;

            DateTime date = DateTime.Now;

            ReservationManager reservManager = new ReservationManager(date);

            reservManager.Table = new List <List <TD> >();

            reservManager.Table = reservManager.GetDayRoomReservation(date, room.Name);

            ViewBag.Date = date;

            ViewBag.Room = room.Name;

            ViewBag.id = "td-day";

            return(View("Room", reservManager));
        }