// 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)); }
// GET: Reservation public ActionResult Home() { TypeRoomModel typeRoomModel = new TypeRoomModel(connectionString); ViewBag.TypeRoom = typeRoomModel.GetAllTypeRoom(); return(View()); }
public ActionResult Rooms() { TypeRoomModel tpm = new TypeRoomModel(); List <TypeRoom> list = tpm.ListAll(); return(View(list)); }
// GET: BookNow public ActionResult Information(List <RoomSelected> model) { HotelDBContext db = new HotelDBContext(); TypeRoomModel tpm = new TypeRoomModel(); OrderModel om = new OrderModel(); double TotalPrice = 0; List <RoomSelected> list = new List <RoomSelected>(); for (int i = 0; i < model.Count; i++) { if (model.ElementAt(i).Checked) { model.ElementAt(i).Price = tpm.FindPrice(model.ElementAt(i).RoomID); double TotalDate = (model.ElementAt(i).ToDate - model.ElementAt(i).FromDate).TotalDays; model.ElementAt(i).TotalPrice = TotalDate * model.ElementAt(i).Price; TotalPrice += model.ElementAt(i).TotalPrice; list.Add(model.ElementAt(i)); } } SearchInput search = (SearchInput)Session["Search"]; if (list.Count != search.NumberOfRoom) { ModelState.AddModelError("NumberOfRoom", $"Please choose {search.NumberOfRoom} room(s)"); ViewBag.TypeRoom = db.TypeRooms.Find(search.TypeRoomID); return(View("~/Views/Home/Search.cshtml", model)); } Bill bill = new Bill(); bill.Total = TotalPrice; bill.Rooms = list; Session["FinalBill"] = bill; return(View(bill)); }
public ActionResult Data(int id) { TypeRoomModel typeRoomModel = new TypeRoomModel(connectionString); TypeRoom typeroom = typeRoomModel.GetTypeRoomByIdRoom(id); ViewBag.TypeRoom = typeroom; return(View()); }
// GET: Home public ActionResult Index() { TypeRoomModel TrModel = new TypeRoomModel(); List <TypeRoom> ListTypeRoom = TrModel.ListAll(); ViewBag.ListTypeRoom = new SelectList(ListTypeRoom, "TypeRoomID", "NameRoom"); return(View()); }
public ActionResult Search(SearchInput model) { HotelDBContext db = new HotelDBContext(); if (ModelState.IsValid) { if ((model.ToDate.Date <= model.FromDate.Date) || (model.FromDate.Date < DateTime.Now.Date)) { ModelState.AddModelError("DateError", "Date is illegal, choose again"); TypeRoomModel TrModel = new TypeRoomModel(); List <TypeRoom> ListTypeRoom = TrModel.ListAll(); ViewBag.ListTypeRoom = new SelectList(ListTypeRoom, "TypeRoomID", "NameRoom"); return(View("Index", model)); } Session["Search"] = model; RoomModel room = new RoomModel(); var ListRoom = room.AvailableRoom(model.TypeRoomID, model.FromDate, model.ToDate); if (ListRoom.Count >= model.NumberOfRoom) { List <RoomSelected> list = new List <RoomSelected>(); foreach (var item in ListRoom) { list.Add(new RoomSelected { RoomID = item.RoomID, FromDate = model.FromDate, ToDate = model.ToDate, Checked = false }); } ViewBag.TypeRoom = db.TypeRooms.Find(model.TypeRoomID); return(View(list)); } else { ViewBag.Message = "There is no room available"; return(View()); } } else { TypeRoomModel TrModel = new TypeRoomModel(); List <TypeRoom> ListTypeRoom = TrModel.ListAll(); ViewBag.ListTypeRoom = new SelectList(ListTypeRoom, "TypeRoomID", "NameRoom"); return(View("Index", model)); } }
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)); }
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")); }
// 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)); }
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)); }
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
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
public IActionResult ReservationList() { ReservationModel repositoryReservation = new ReservationModel(connectionString); IList <Reservation> reservation = repositoryReservation.GetAllReservation(); List <ReservationModel> reservationModel = new List <ReservationModel>(); ClientModel client = new ClientModel(connectionString); IList <Client> listclient = client.GetAllClients(); List <ClientModel> clientModel = new List <ClientModel>(); PaymentcardModel paymentcard = new PaymentcardModel(connectionString); IList <Paymentcard> listPaymentcard = paymentcard.GetAllPaymentcard(); List <PaymentcardModel> paymentcardModel = new List <PaymentcardModel>(); VoucherModel voucher = new VoucherModel(connectionString); IList <Voucher> listVoucher = voucher.GetAllVoucher(); List <VoucherModel> voucherModel = new List <VoucherModel>(); RoomModel room = new RoomModel(connectionString); IList <Room> listRoom = room.GetAllRoom(); TypeRoomModel typeroom = new TypeRoomModel(connectionString); IList <TypeRoom> listTyperoom = typeroom.GetAllTypeRooms(); List <TypeRoomModel> typeRoomModel = new List <TypeRoomModel>(); for (int i = 0; i < listVoucher.Count; i++) { VoucherModel voucherNew = new VoucherModel(); voucherNew.id = listVoucher[i].id; voucherNew.idpaymentcard = listVoucher[i].idpaymentcard; voucherNew.idreservation = listVoucher[i].idreservation; voucherNew.creationdate = listVoucher[i].creationdate; voucherModel.Add(voucherNew); for (int j = 0; j < reservation.Count; j++) { if (listVoucher[i].idreservation.Equals(reservation[j].id)) { ReservationModel reservationNew = new ReservationModel(); reservationNew.id = reservation[j].id; reservationNew.idroom = reservation[j].idroom; reservationNew.idclient = reservation[j].idclient; reservationNew.arrivaldate = reservation[j].arrivaldate; reservationNew.departuredate = reservation[j].departuredate; reservationModel.Add(reservationNew); for (int k = 0; k < listclient.Count; k++) { if (reservation[j].idclient.Equals(listclient[k].id)) { ClientModel clientNew = new ClientModel(); clientNew.id = listclient[k].id; clientNew.name = listclient[k].name; clientNew.lastname = listclient[k].lastname; clientNew.email = listclient[k].email; clientModel.Add(clientNew); } } for (int k = 0; k < listRoom.Count; k++) { if (reservation[j].idroom.Equals(listRoom[k].id)) { for (int f = 0; f < listTyperoom.Count; f++) { if (listRoom[k].idtyperoom.Equals(listTyperoom[f].id)) { TypeRoomModel typeRoomNew = new TypeRoomModel(); typeRoomNew.description = listTyperoom[f].description; typeRoomModel.Add(typeRoomNew); } } } } } } for (int k = 0; k < listPaymentcard.Count; k++) { if (listPaymentcard[k].id.Equals(listVoucher[i].idpaymentcard)) { PaymentcardModel paymentcardNew = new PaymentcardModel(); paymentcardNew.cardnumber = listPaymentcard[k].cardnumber; paymentcardModel.Add(paymentcardNew); } } } ViewBag.paymentcard = paymentcardModel; ViewBag.voucher = voucherModel; ViewBag.reservation = reservationModel; ViewBag.typeroom = typeRoomModel; ViewBag.client = clientModel; return(View()); }
public ActionResult Confirmation(int identification, string name, string lastname, string email, int idroom, int amount, string arrivaldate, string departuredate, int paymentcardid) { ClientModel clientModel = new ClientModel(connectionString); ReservationModel reservationModel = new ReservationModel(connectionString); Client clientResult = clientModel.GetClientByidentification(identification); SendMail sendMail = null; RoomModel roomModel = new RoomModel(connectionString); Room newRoom = roomModel.GetRoomById(idroom); TypeRoomModel typeRoomModel = new TypeRoomModel(connectionString); TypeRoom newTypeRoom = typeRoomModel.GetTypeRoomByIdRoom(newRoom.id); if (clientResult == null) { Client newclient = new Client() { id = 0, identification = identification, name = name, lastname = lastname, email = email }; clientResult = clientModel.AddClient(newclient); } Reservation reservation = new Reservation() { id = 0, idroom = idroom, idClient = clientResult.id, amount = amount, arrivaldate = arrivaldate, departuredate = departuredate, creationdate = DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss") }; Reservation resultReservation = reservationModel.AddReservation(reservation); if (resultReservation != null) { sendMail = new SendMail() { email = clientResult.email, name = clientResult.name, lastname = clientResult.lastname, identification = clientResult.identification, action = ".Su reserva en la habitación tipo " + newTypeRoom.description + " número " + newRoom.number + " ha sido exitosa, para el día " + reservation.arrivaldate + " y hasta " + reservation.departuredate + " por un monto total de " + reservation.amount + " dolares." }; sendMail.SendMailAction(); PaymentCardModel paymentModel = new PaymentCardModel(connectionString); var result = paymentModel.AddVoucher(paymentcardid, resultReservation.id); if (result < 1) { return(View("Data")); } } ViewBag.Reservation = reservation; ViewBag.Client = clientResult; ViewBag.Email = sendMail; return(View()); }
public AdministratorAvailabilityController(IConfiguration configuration) { _configuration = configuration; connectionString = _configuration.GetConnectionString("DefaultConnection"); typeRoomModal = new TypeRoomModel(connectionString); }