public void AddNewRoom(NewRoomModel room)
        {
            Entities db = new Entities();

            if (ModelState.IsValid && room.Capacity != 0)
            {
                Auditorium auditorium = new Auditorium();

                auditorium.AuditoriumName = room.Name;

                auditorium.Capacity = room.Capacity;

                db.Auditorium.Add(auditorium);

                db.SaveChanges();

                int auditoriumId = db.Auditorium.Where(aud => aud.AuditoriumName.Equals(room.Name)).First().AuditoriumId;

                if (room.Wifi)
                {
                    int wifi = db.AdditionalEquipment.Where(addeq => addeq.AdditionalEquipmentName.Equals("Wifi")).First().AdditionalEquipmentId;

                    db.InsertAudEq(auditoriumId, wifi);
                }

                if (room.Monitor)
                {
                    int monitor = db.AdditionalEquipment.Where(addeq => addeq.AdditionalEquipmentName.Equals("Монитор")).First().AdditionalEquipmentId;

                    db.InsertAudEq(auditoriumId, monitor);
                }

                if (room.Projector)
                {
                    int projector = db.AdditionalEquipment.Where(addeq => addeq.AdditionalEquipmentName.Equals("Проектор")).First().AdditionalEquipmentId;

                    db.InsertAudEq(auditoriumId, projector);
                }

                if (room.Microphone)
                {
                    int microphone = db.AdditionalEquipment.Where(addeq => addeq.AdditionalEquipmentName.Equals("Микрофон")).First().AdditionalEquipmentId;

                    db.InsertAudEq(auditoriumId, microphone);
                }

                db.SaveChanges();
            }
        }
        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);
        }
        public ActionResult IsRoomExist(NewRoomModel room)
        {
            Validation answer = new Validation();

            IQueryable<Auditorium> rooms = db.Auditorium.Where(a => a.AuditoriumName.Equals(room.Name));

            if (rooms.Count() == 0)
            {
                answer.IsValid = false;

                answer.Message = "Указанная аудитория не найдена";
            }
            else
            {
                answer.IsValid = true;

                answer.Message = "Указанная аудитория найдена";
            }

            return Json(answer, JsonRequestBehavior.AllowGet);
        }