コード例 #1
0
        // GET: Facilities
        public ActionResult Home()
        {
            RepositoryTypeRoom   repositoryTypeRoom = new RepositoryTypeRoom(connectionString);
            IList <TypeRoom>     typeRoom           = repositoryTypeRoom.GetAllTypeRoom();
            List <TypeRoomModel> typeRoomModel      = new List <TypeRoomModel>();
            DateTime             date = DateTime.Today;

            for (int i = 0; i < typeRoom.Count; i++)
            {
                TypeRoomModel typeRoomNew = new TypeRoomModel(connectionString);
                typeRoomNew.quantityperson      = typeRoom[i].quantityperson;
                typeRoomNew.quantitybed         = typeRoom[i].quantitybed;
                typeRoomNew.description         = typeRoom[i].description;
                typeRoomNew.amount              = typeRoom[i].amount;
                typeRoomNew.urlimage            = typeRoom[i].urlimage;
                typeRoomNew.descriptiontyperoom = typeRoom[i].descriptiontyperoom;
                if (date.ToString("MM") == "12" || date.ToString("MM") == "01" || date.ToString("MM") == "02" || date.ToString("MM") == "03")
                {
                    typeRoomNew.amount += Convert.ToInt32(typeRoomNew.amount * 0.1);
                }

                typeRoomModel.Add(typeRoomNew);
            }

            return(View(typeRoomModel));
        }
コード例 #2
0
        public JsonResult GetManageRooms(string description)
        {
            RepositoryTypeRoom repositoryTyperoom = new RepositoryTypeRoom(connectionString);
            List <TypeRoom>    typeRoom           = repositoryTyperoom.GetAllTypeRoom();
            TypeRoom           typeRoomNew        = new TypeRoom();

            typeRoomNew = typeRoom.Find(r => r.description == description);
            counter     = description;
            return(Json(typeRoomNew));
        }
コード例 #3
0
        public ActionResult DeleteSeason(int id)
        {
            RepositoryTypeRoom   repositoryTyperoom = new RepositoryTypeRoom(connectionString);
            SeasonModel          seasonModel        = new SeasonModel(connectionString);
            List <TypeRoomModel> typeroomModel      = new List <TypeRoomModel>();
            IList <TypeRoom>     typeRoom           = repositoryTyperoom.GetAllTypeRoom();

            for (int j = 0; j < typeRoom.Count; j++)
            {
                TypeRoomModel typeRoomNew = new TypeRoomModel(connectionString);
                typeRoomNew.description = typeRoom[j].description;
                typeRoomNew.id          = typeRoom[j].id;
                typeroomModel.Add(typeRoomNew);
            }

            seasonModel.DeleteSeason(id);
            Season();

            return(View("Season", typeroomModel));
        }
コード例 #4
0
        public ActionResult Update(IFormFile file, string descriptionArea, string amount)
        {
            string descriptionType = counter;

            RepositoryTypeRoom   repositoryTyperoom = new RepositoryTypeRoom(connectionString);
            IList <TypeRoom>     typeRoom           = repositoryTyperoom.GetAllTypeRoom();
            List <TypeRoomModel> typeroomModel      = new List <TypeRoomModel>();

            string urlimage          = "";
            var    path              = "./images/TipoHabitacion/";
            var    pathClient        = "../../../Client/Presentation/wwwroot/images/TipoHabitacion/";
            string folderFiles       = Path.Combine(environment.WebRootPath, path);
            string folderFilesClient = Path.Combine(environment.WebRootPath, pathClient);

            int idTypeRoom = 0;

            if (file != null)
            {
                repositoryTyperoom.SaveImage(file, folderFiles);
                repositoryTyperoom.SaveImage(file, folderFilesClient);
                urlimage = "/images/TipoHabitacion/" + file.FileName;
            }
            for (int i = 0; i < typeRoom.Count; i++)
            {
                if (typeRoom[i].description == descriptionType)
                {
                    idTypeRoom = typeRoom[i].id;
                    if (file == null)
                    {
                        urlimage = typeRoom[i].urlimage;
                    }
                }

                TypeRoomModel typeRoomNew = new TypeRoomModel(connectionString);
                typeRoomNew.description = typeRoom[i].description;
                typeroomModel.Add(typeRoomNew);
            }
            repositoryTyperoom.UpdateTypeRoom(descriptionArea, amount, urlimage, idTypeRoom);

            return(RedirectToAction("ManageRooms"));
        }
コード例 #5
0
        // GET: /<controller>/
        public IActionResult ManageRooms()
        {
            RepositoryTypeRoom   repositoryTyperoom = new RepositoryTypeRoom(connectionString);
            IList <TypeRoom>     typeRoom           = repositoryTyperoom.GetAllTypeRoom();
            TypeRoomModel        typeRoomModel      = new TypeRoomModel(connectionString);
            List <TypeRoomModel> typeroomModel      = new List <TypeRoomModel>();

            RoomModel        room      = new RoomModel(connectionString);
            IList <Room>     listRoom  = room.GetAllRoom();
            List <RoomModel> roomModel = new List <RoomModel>();

            ReservationModel        reservation      = new ReservationModel(connectionString);
            IList <Reservation>     listReservation  = reservation.GetAllReservation();
            List <ReservationModel> reservationModel = new List <ReservationModel>();

            for (int i = 0; i < listRoom.Count; i++)
            {
                RoomModel roomNew = new RoomModel(connectionString);
                roomNew.state      = listRoom[i].state;
                roomNew.number     = listRoom[i].number;
                roomNew.idtyperoom = listRoom[i].idtyperoom;
                roomModel.Add(roomNew);
            }
            for (int j = 0; j < typeRoom.Count; j++)
            {
                TypeRoomModel typeRoomNew = new TypeRoomModel(connectionString);
                typeRoomNew.description = typeRoom[j].description;
                typeRoomNew.id          = typeRoom[j].id;
                typeroomModel.Add(typeRoomNew);
            }
            for (int j = 0; j < listReservation.Count; j++)
            {
                ReservationModel reservationNew = new ReservationModel(connectionString);
                reservationNew.idroom = listReservation[j].idroom;
                reservationModel.Add(reservationNew);
            }
            ViewBag.reservation = reservationModel;
            ViewBag.room        = roomModel;
            return(View(typeroomModel));
        }
コード例 #6
0
        public ActionResult insert(string description, string dateinputseason, string dateoutputseason, string descriptionText, int percentation)
        {
            RepositoryTypeRoom repositoryTyperoom = new RepositoryTypeRoom(connectionString);
            SeasonModel        seasonModel        = new SeasonModel(connectionString);

            IList <TypeRoom> typeRoom          = repositoryTyperoom.GetAllTypeRoom();
            int idtyperoom                     = 0;
            List <TypeRoomModel> typeroomModel = new List <TypeRoomModel>();

            for (int j = 0; j < typeRoom.Count; j++)
            {
                TypeRoomModel typeRoomNew = new TypeRoomModel(connectionString);
                typeRoomNew.description = typeRoom[j].description;
                typeRoomNew.id          = typeRoom[j].id;
                if (description.Equals(typeRoom[j].description))
                {
                    idtyperoom = typeRoom[j].id;
                }
                typeroomModel.Add(typeRoomNew);
            }

            if (idtyperoom != 0 || percentation != 0)
            {
                seasonModel.InsertSeason(idtyperoom, idtyperoom, dateinputseason, dateoutputseason, descriptionText, 1, percentation);
            }


            idtyperoom       = 0;
            percentation     = 0;
            dateinputseason  = null;
            dateoutputseason = null;
            descriptionText  = null;


            Season();

            return(View("Season", typeroomModel));
        }
コード例 #7
0
        public IActionResult Season()
        {
            SeasonModel        seasonModel     = new SeasonModel(connectionString);
            IList <Season>     season          = seasonModel.GetAllSeason();
            List <SeasonModel> seasonModellist = new List <SeasonModel>();

            RepositoryTypeRoom repositoryTyperoom = new RepositoryTypeRoom(connectionString);
            IList <TypeRoom>   typeRoom           = repositoryTyperoom.GetAllTypeRoom();

            List <TypeRoomModel> typeroomModel = new List <TypeRoomModel>();

            for (int i = 0; i < season.Count; i++)
            {
                SeasonModel reservationNew = new SeasonModel();
                reservationNew.id               = season[i].id;
                reservationNew.idtyperoom       = season[i].idtyperoom;
                reservationNew.percentation     = season[i].percentation;
                reservationNew.state            = season[i].state;
                reservationNew.dateinputseason  = season[i].dateinputseason;
                reservationNew.dateoutputseason = season[i].dateoutputseason;
                reservationNew.description      = season[i].description;
                seasonModellist.Add(reservationNew);
            }

            for (int j = 0; j < typeRoom.Count; j++)
            {
                TypeRoomModel typeRoomNew = new TypeRoomModel(connectionString);
                typeRoomNew.description = typeRoom[j].description;
                typeRoomNew.id          = typeRoom[j].id;
                typeroomModel.Add(typeRoomNew);
            }

            ViewBag.type   = typeroomModel;
            ViewBag.season = seasonModellist;
            return(View(typeroomModel));
        }//State
コード例 #8
0
        public IActionResult State()
        {
            ReservationModel        repositoryReservation = new ReservationModel(connectionString);
            IList <Reservation>     reservation           = repositoryReservation.GetAllReservation();
            List <ReservationModel> reservationModel      = new List <ReservationModel>();

            List <ReservationModel> reservationModelfree = new List <ReservationModel>();


            RepositoryTypeRoom   repositoryTyperoom = new RepositoryTypeRoom(connectionString);
            IList <TypeRoom>     typeRoom           = repositoryTyperoom.GetAllTypeRoom();
            List <TypeRoomModel> typeroomModel      = new List <TypeRoomModel>();

            List <TypeRoomModel> typeroomModelfree = new List <TypeRoomModel>();


            RoomModel        repositoryroom = new RoomModel(connectionString);
            IList <Room>     room           = repositoryroom.GetAllRoom();
            List <RoomModel> roomModel      = new List <RoomModel>();

            List <RoomModel> roomModelfree = new List <RoomModel>();

            string   date         = DateTime.Now.ToString("yyyy-MM-dd");
            DateTime enteredDate1 = DateTime.Parse(date);

            for (int i = 0; i < reservation.Count; i++)
            {
                ReservationModel reservationNew = new ReservationModel();
                reservationNew.idroom      = reservation[i].idroom;
                reservationNew.arrivaldate = reservation[i].arrivaldate;
                string   strDate      = reservation[i].arrivaldate.ToString("yyyy-MM-dd");
                string   strDate1     = reservation[i].departuredate.ToString("yyyy-MM-dd");
                DateTime enteredDate2 = DateTime.Parse(strDate);
                DateTime enteredDate3 = DateTime.Parse(strDate1);

                for (int j = 0; j < room.Count; j++)
                {
                    if (reservationNew.idroom.Equals(room[j].id) && (enteredDate1 >= enteredDate2 && enteredDate1 <= enteredDate3))
                    {
                        RoomModel RoomNew = new RoomModel(connectionString);
                        RoomNew.id         = room[j].id;
                        RoomNew.number     = room[j].number;
                        RoomNew.idtyperoom = room[j].idtyperoom;

                        for (int k = 0; k < typeRoom.Count; k++)
                        {
                            if (RoomNew.idtyperoom.Equals(typeRoom[k].id))
                            {
                                TypeRoomModel typeRoomNew = new TypeRoomModel(connectionString);
                                typeRoomNew.id          = typeRoom[k].id;
                                typeRoomNew.description = typeRoom[k].description;
                                typeroomModel.Add(typeRoomNew);
                                reservationModel.Add(reservationNew);
                                roomModel.Add(RoomNew);
                            }
                        } //tercer for
                    }     /// if reservation with Room
                }         //segundo for
            }             //primer for

            for (int i = 0; i < reservation.Count; i++)
            {
                ReservationModel reservationNew = new ReservationModel();
                reservationNew.idroom = reservation[i].idroom;
                string strDate = reservation[i].arrivaldate.ToString("yyyy-MM-dd");

                for (int j = 0; j < room.Count; j++)
                {
                    if (reservationNew.idroom.Equals(room[j].id) && !strDate.Equals(date))
                    {
                        RoomModel RoomNew = new RoomModel(connectionString);
                        RoomNew.id         = room[j].id;
                        RoomNew.number     = room[j].number;
                        RoomNew.idtyperoom = room[j].idtyperoom;

                        for (int k = 0; k < typeRoom.Count; k++)
                        {
                            if (RoomNew.idtyperoom.Equals(typeRoom[k].id))
                            {
                                TypeRoomModel typeRoomNew = new TypeRoomModel(connectionString);
                                typeRoomNew.id          = typeRoom[k].id;
                                typeRoomNew.description = typeRoom[k].description;
                                typeroomModelfree.Add(typeRoomNew);
                                reservationModelfree.Add(reservationNew);
                                roomModelfree.Add(RoomNew);
                            }
                        } //tercer for
                    }     /// if reservation with Room
                }         //segundo for
            }             //primer for

            ViewBag.roomfree        = roomModelfree;
            ViewBag.typeroomfree    = typeroomModelfree;
            ViewBag.reservationfree = reservationModelfree;
            ViewBag.room            = roomModel;
            ViewBag.typeroom        = typeroomModel;
            ViewBag.reservation     = reservationModel;

            return(View());
        }//State