//Devuelve una cadena que muestra las propiedades de un cliente public override string ToString() { string strOutput = ""; strOutput += "DETALLES DE RESERVA" + Environment.NewLine + "Fecha de entrada: " + CheckInDate.ToLongDateString() + Environment.NewLine + "Numero de noches: " + NumberOfNights.ToString() + Environment.NewLine + "Tipo de cuarto: " + RoomType + Environment.NewLine + "Numero de cuartos: " + NumberOfRooms.ToString() + Environment.NewLine + "Precio de cuarto: " + RoomPrice.ToString("C2") + Environment.NewLine + "Subtotal: " + SubTotal.ToString("C2") + Environment.NewLine + "Iva (19%): " + Tax.ToString("C2") + Environment.NewLine + "Gravamen de Hospedaje: " + ConvenienceFee.ToString("C2") + Environment.NewLine + "Total: " + Total.ToString("C2") + Environment.NewLine + Environment.NewLine + "DETALLES DE CLIENTE" + Environment.NewLine + "Nombres: " + FirstName + Environment.NewLine + "Apellidos: " + LastName + Environment.NewLine + "Numero de TDC: " + CreditCardNumber + Environment.NewLine + "Tipo de tarjeta: " + CreditCardType + Environment.NewLine + "Telefono: " + Phone + Environment.NewLine + "Email: " + Email + Environment.NewLine; return(strOutput); }
internal IRoomPrice GetRoomPrice(RoomType RType) { connect(); RoomPrice roomprice = null; SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM RoomPrice WHERE RTYPE = '" + RType.ToString() + "'", sqlCon); try { SQLiteDataReader rdr = cmd.ExecuteReader(); if (rdr.Read()) { roomprice = new RoomPrice ( (RoomType)Enum.Parse(typeof(RoomType), rdr["RTYPE"].ToString()), double.Parse(rdr["RPRICE"].ToString()) ); } rdr.Close(); return(roomprice); } catch (Exception ex) { throw new Exception("Failed to parse/create new roomprice!\n" + ex.Message); } finally { disconnect(); } }
public IHttpActionResult PostNewHotelPrice(RoomPrice roomPrice) { if (roomPrice == null) { return(BadRequest("Please provide valid room prices")); } if (!ModelState.IsValid) { string modelErrors = string.Join(Environment.NewLine, ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); return(BadRequest(modelErrors)); } try { bool response = hotelManager.AddNewHotelRoomPrice(roomPrice); if (!response) { return(ResponseMessage(Request.CreateErrorResponse((HttpStatusCode)422, new HttpError("Unprossesed Entity! Something went wrong while adding room prices")))); } else { return(Ok()); } } catch (Exception e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Some Error Occoured While adding the room price value"))); } }
public async Task <IActionResult> Edit(long id, [Bind("Id,RoomType,Price")] RoomPrice roomPrice) { if (id != roomPrice.Id) { return(NotFound()); } if (ModelState.IsValid) { if (_context.RoomPrices.Any(rp => rp.RoomType == roomPrice.RoomType && rp.Id != id)) { ModelState.AddModelError("RoomType", "Price for selected room type exists."); return(View(roomPrice)); } try { _context.Update(roomPrice); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomPriceExists(roomPrice.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(roomPrice)); }
public JsonResult Edit(long id, string saleName, decimal sale, long roomTypeId, DateTime startDate, DateTime endDate, string remark) { var apiResult = new APIResult(); try { var model = new RoomPrice() { Id = id, SaleName = saleName, Sale = sale, RoomTypeId = roomTypeId, StartDate = TypeConvert.DateTimeToInt(startDate), EndDate = TypeConvert.DateTimeToInt(endDate), Remark = remark, }; RoomPriceBll.AddOrUpdate(model, UserContext.CurrentUser.HotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public async Task <IActionResult> Edit(int id, [Bind("RoomPriceID,RoomPriceAmount")] RoomPrice roomPrice) { if (id != roomPrice.RoomPriceID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(roomPrice); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomPriceExists(roomPrice.RoomPriceID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(roomPrice)); }
//Returns a string that displays a customer's properties public override string ToString() { string strOutput = ""; strOutput += "RESERVATION DETAILS" + Environment.NewLine + "Check in date: " + CheckInDate.ToLongDateString() + Environment.NewLine + "Number of nights: " + NumberOfNights.ToString() + Environment.NewLine + "Room type: " + RoomType + Environment.NewLine + "Number of rooms: " + NumberOfRooms.ToString() + Environment.NewLine + "Room price: " + RoomPrice.ToString("C2") + Environment.NewLine + "Subtotal: " + SubTotal.ToString("C2") + Environment.NewLine + "Tax (7%): " + Tax.ToString("C2") + Environment.NewLine + "Convenience Fee: " + ConvenienceFee.ToString("C2") + Environment.NewLine + "Total: " + Total.ToString("C2") + Environment.NewLine + Environment.NewLine + "CUSTOMER DETAILS" + Environment.NewLine + "First Name: " + FirstName + Environment.NewLine + "Last Name: " + LastName + Environment.NewLine + "Credit Card Number: " + CreditCardNumber + Environment.NewLine + "Credit Card Type: " + CreditCardType + Environment.NewLine + "Phone: " + Phone + Environment.NewLine + "Email: " + Email + Environment.NewLine; return(strOutput); }
public async Task <IActionResult> Create([Bind("RoomPriceID,RoomPriceAmount")] RoomPrice roomPrice) { if (ModelState.IsValid) { _context.Add(roomPrice); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(roomPrice)); }
public void AddHotelPrice(RoomPrice price) { try { db.RoomPrices.Add(price); db.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw new DbUpdateConcurrencyException(); } }
public void updateHotelPrice(RoomPrice price) { db.Entry(price).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw new Exception(); } }
public void AddNewTest() { var room = _context.Set <Room>().FirstOrDefault(s => s.RoomCode == "R0010"); var price = new RoomPrice { Price = 500, RoomId = room.Id, PriceDate = DateTime.Now }; price.Created(Guid.NewGuid()); _priceRepository.Add(price); Assert.True(_context.SaveChangesAsync().Result); }
public bool NewHotelRoomPriceAdder(RoomPrice roomPrice) { db.RoomPrices.Add(roomPrice); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(false); throw new Exception(); } return(true); }
public async Task <IActionResult> Create([Bind("Id,RoomType,Price")] RoomPrice roomPrice) { if (ModelState.IsValid) { if (_context.RoomPrices.Any(rp => rp.RoomType == roomPrice.RoomType)) { ModelState.AddModelError("RoomType", "Price for selected room type exists."); return(View(roomPrice)); } _context.Add(roomPrice); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(roomPrice)); }
public int calculateRoomPrice(String RoomType, DateTime checkIn, DateTime checkOut, int NoOfRooms) { RoomType roomType = Booking.converToEnum <RoomType>(RoomType); DateTime tempDate = checkIn; RoomPrice roomPrice = _roomPricesRepository.GetRoomPrice(roomType, tempDate); int cost = 0; while (checkOut >= tempDate) { if (roomPrice.EndDate < tempDate) { roomPrice = _roomPricesRepository.GetRoomPrice(roomType, tempDate); } cost += roomPrice.Price; tempDate = tempDate.AddDays(1); } cost = cost * NoOfRooms; return(cost); }
public bool AddNewHotelRoomPrice(RoomPrice roomPrice) { return(adminHotelManager.NewHotelRoomPriceAdder(roomPrice)); }
public static void Initialize(Context context) { context.Database.EnsureCreated(); // Look for any Customers. if (context.Customers.Any()) { return; // DB has been seeded } // Customers var customers = new Customer[] { new Customer { CustomerID = 100, CustomerTitle = "Standard", CustomerForenames = "Hernandez", CustomerSurnames = "Pedro", CustomerDOB = DateTime.Parse("1992-09-01"), CustomerAddressStreet = "Calle 1", CustomerAddressTown = "Zacatecas", CustomerAddressCountry = "Mexico", CustomerAddressPostalCode = "98000", CustomerHomePhone = "4928896558", CustomerWorkPhone = "4927796251", CustomerMobilPhone = "4988898521", CustomerEmail = "*****@*****.**" } }; foreach (Customer s in customers) { context.Customers.Add(s); } context.SaveChanges(); // Booking * var bookings = new Booking[] { new Booking { BookingID = 10, CustomerID = customers.Single(c => c.CustomerSurnames == "Pedro").CustomerID, DateBookingMade = DateTime.Parse("2020-09-01"), TimeBookingMade = DateTime.Parse("2020-09-01"), BookedStartDate = DateTime.Parse("2020-09-02"), BookedEndDate = DateTime.Parse("2020-09-06"), TotalPaymentDueDate = DateTime.Parse("2020-09-06"), TotalPaymentDueAmount = 2500, TotalPaymentMadeOn = DateTime.Parse("2020-09-06"), BookingComments = "Reservación correcta" } }; foreach (Booking i in bookings) { context.Bookings.Add(i); } context.SaveChanges(); // FacilitieList var facilitieLists = new FacilitieList[] { new FacilitieList { FacilityID = 1, FacilityDesc = "Jacuzzi" } }; foreach (FacilitieList i in facilitieLists) { context.FacilitieLists.Add(i); } context.SaveChanges(); // PaymentMethod var paymentMethods = new PaymentMethod[] { new PaymentMethod { PaymentMethodID = 1, PaymentMethodDesc = "Debit Card" } }; foreach (PaymentMethod i in paymentMethods) { context.PaymentMethods.Add(i); } context.SaveChanges(); // Payment var payments = new Payment[] { new Payment { PaymentID = 1, BookingID = bookings.Single(c => c.BookingID == 10).BookingID, CustomerID = customers.Single(c => c.CustomerID == 100).CustomerID, //PEdro PaymentMethodID = paymentMethods.Single(p => p.PaymentMethodID == 1).PaymentMethodID, PaymentAmount = 5000, PaymentComments = "Todo en orden" } }; foreach (Payment i in payments) { context.Payments.Add(i); } context.SaveChanges(); // Guests var guests = new Guest[] { new Guest { GuestID = 123, GuestTitle = "Teacher", GuestForenames = "Perez", GuestSurnames = "Pancho", GuestDOB = DateTime.Parse("1996-09-01"), GuestAddressStreet = "Calle primavera 5", GuestAddressTown = "Zacatecas", GuestAddressCountry = "Mexico", GuestAddressPostalCode = "98600", GuestContactPhone = "1651254305" } }; foreach (Guest i in guests) { context.Guests.Add(i); } context.SaveChanges(); // RoomType var roomtypes = new RoomType[] { new RoomType { RoomTypeID = 1, RoomTypeDesc = "Suite 5 stars" } }; foreach (RoomType i in roomtypes) { context.RoomTypes.Add(i); } context.SaveChanges(); // RoomBand var roomBands = new RoomBand[] { new RoomBand { RoombandID = 1, BandDesc = "5 beds" } }; foreach (RoomBand i in roomBands) { context.RoomBands.Add(i); } context.SaveChanges(); // RoomPrice var roomPrices = new RoomPrice[] { new RoomPrice { RoomPriceID = 1, RoomPriceDesc = 5000 }, new RoomPrice { RoomPriceID = 2, RoomPriceDesc = 2500 } }; foreach (RoomPrice i in roomPrices) { context.RoomPrices.Add(i); } context.SaveChanges(); // Rooms * var rooms = new Room[] { new Room { RoomID = 502, RoomTypeID = roomtypes.Single(c => c.RoomTypeID == 1).RoomTypeID, RoomBandID = roomBands.Single(i => i.RoombandID == 1).RoombandID, RoomPriceID = roomPrices.Single(r => r.RoomPriceID == 2).RoomPriceID, Floor = "5th Floor", AdditionalNotes = "Excellent View" } }; foreach (Room i in rooms) { context.Rooms.Add(i); } context.SaveChanges(); // RoomFacility var roomFacilities = new RoomFacility[] { new RoomFacility { RoomID = rooms.Single(c => c.RoomID == 502).RoomID, FacilityID = facilitieLists.Single(c => c.FacilityID == 1).FacilityID, FacilityDetails = "Realizado con exito", } }; foreach (RoomFacility i in roomFacilities) { context.RoomFacilities.Add(i); } context.SaveChanges(); //BookingRoom var bookingRooms = new BookingRoom[] { new BookingRoom { BookingID = bookings.Single(c => c.BookingID == 10).BookingID, RoomID = rooms.Single(c => c.RoomID == 502).RoomID, GuestID = guests.Single(c => c.GuestID == 123).GuestID } }; foreach (BookingRoom i in bookingRooms) { context.BookingRooms.Add(i); } context.SaveChanges(); }
public override void Run(DataContext context) { var currDate = DateTime.Today; var currYear = currDate.Year; var WeekDay = new DayEffect() { CanDelete = false, Effect = "WEEKDAY", EffectColor = "green darken-1", }; var WeekEnd = new DayEffect() { CanDelete = false, Effect = "WEEKEND", EffectColor = "red darken-2", }; var Holiday = new DayEffect() { CanDelete = false, Effect = "HOLIDAY", EffectColor = "teal darken-4", }; context.DayEffect.Add(WeekDay); context.DayEffect.Add(WeekEnd); context.DayEffect.Add(Holiday); context.SaveChanges(); for (var i = new DateTime(currYear, 1, 1); i < new DateTime(currYear + 1, 1, 1);) { var cycle = new DayCycle() { DateAt = i, IdEffect = (i.DayOfWeek == DayOfWeek.Sunday) ? WeekEnd.Id : WeekDay.Id }; context.DayCycles.Add(cycle); i = i.AddDays(1.0d); } context.SaveChanges(); var categories = (from a in context.RoomCategory select a).ToList(); var effects = (from a in context.DayEffect select a).ToList(); foreach (var effect in effects) { foreach (var category in categories) { var price = new RoomPrice() { IdCategory = category.Id, IdEffect = effect.Id, Price = (new Random().Next(100, 200)) * 1000 }; context.RoomPrice.Add(price); } } context.SaveChanges(); }
public static void Initializate(HotelContext context) { context.Database.EnsureCreated(); if (context.FacilitieLists.Any()) { return; //la base de dats ya tiene datos } var FacilitieList = new FacilitieList[] { new FacilitieList { FacilityID = 1, FacilityDesc = "facilitr1" }, new FacilitieList { FacilityID = 2, FacilityDesc = "facilitr2" }, new FacilitieList { FacilityID = 3, FacilityDesc = "facilitr3" } }; foreach (FacilitieList q in FacilitieList) { context.FacilitieLists.Add(q); } context.SaveChanges(); //Guest var Guest = new Guest[] { new Guest { GuestID = 1, GuestTitle = "1", GuestForenames = "Carlos", GuestSurnames = "Lopez", GuestDOB = DateTime.Parse("1/1/2018"), GuestAddressCountry = "México", GuestAddressTown = "Zacatecas", GuestAddressStreet = "Insurgentes", GuestAddressPostaleCode = "98000", GuestContactPhone = "4987563651" }, new Guest { GuestID = 2, GuestTitle = "2", GuestForenames = "Manuel", GuestSurnames = "Hernandez", GuestDOB = DateTime.Parse("2/2/2018"), GuestAddressCountry = "México", GuestAddressTown = "Zacatecas", GuestAddressStreet = "Morelos", GuestAddressPostaleCode = "98000", GuestContactPhone = "4596878963" }, new Guest { GuestID = 3, GuestTitle = "3", GuestForenames = "Maria", GuestSurnames = "Benitez", GuestDOB = DateTime.Parse("2/2/2018"), GuestAddressCountry = "México", GuestAddressTown = "Jalisco", GuestAddressStreet = "Hacienda nueva", GuestAddressPostaleCode = "96000", GuestContactPhone = "4469878963" } }; foreach (Guest u in Guest) { context.Guests.Add(u); } context.SaveChanges(); //Customer var Customer = new Customer[] { new Customer { CustomerID = 1, CustomerTitle = "1", CustomerForenames = "Guadalupe", CustomerSurnames = "Gonzalez", CustomerDOB = DateTime.Parse("1/1/2019"), CustomerAddressCountry = "España", CustomerAddressTown = "España", CustomerAddressStreet = "España", CustomerAddressPostalCode = "1236", CustomerCustomEmail = "*****@*****.**", CustomerHomePhone = "6987453210" }, new Customer { CustomerID = 2, CustomerTitle = "2", CustomerForenames = "Alejandro", CustomerSurnames = "Betancourth", CustomerDOB = DateTime.Parse("2/2/2019"), CustomerAddressCountry = "USA", CustomerAddressTown = "Los Angeles", CustomerAddressStreet = "California", CustomerAddressPostalCode = "9874", CustomerCustomEmail = "*****@*****.**", CustomerHomePhone = "3698741225" }, new Customer { CustomerID = 3, CustomerTitle = "3", CustomerForenames = "Alicia", CustomerSurnames = "Jara", CustomerDOB = DateTime.Parse("3/3/2019"), CustomerAddressCountry = "Mexico", CustomerAddressTown = "Zacatecas", CustomerAddressStreet = "Zacatecas", CustomerAddressPostalCode = "98000", CustomerCustomEmail = "*****@*****.**", CustomerHomePhone = "4589632123" } }; foreach (Customer i in Customer) { context.Customers.Add(i); } context.SaveChanges(); //Roomtypes var RoomType = new RoomType[] { new RoomType { RoomTypeID = 1, RoomTypes = "Individual" }, new RoomType { RoomTypeID = 2, RoomTypes = "Compartido" }, new RoomType { RoomTypeID = 3, RoomTypes = "Matrimonial" } }; foreach (RoomType e in RoomType) { context.RoomTypes.Add(e); } context.SaveChanges(); //RoomBand var RoomBand = new RoomBand[] { new RoomBand { RoomBandID = 1, BandDesc = "Band1" }, new RoomBand { RoomBandID = 2, BandDesc = "Band2" }, new RoomBand { RoomBandID = 3, BandDesc = "Band3" } }; foreach (RoomBand r in RoomBand) { context.RoomBands.Add(r); } context.SaveChanges(); //RoomPrice var RoomPrice = new RoomPrice[] { new RoomPrice { RoomPriceID = 1, RoomPrices = 1000 }, new RoomPrice { RoomPriceID = 2, RoomPrices = 1500 }, new RoomPrice { RoomPriceID = 3, RoomPrices = 2000 } }; foreach (RoomPrice t in RoomPrice) { context.RoomPrices.Add(t); } context.SaveChanges(); //Room var Room = new Room[] { new Room { RoomID = 1, RoomTypeID = 1, RoomBandID = 1, RoomPriceID = 1, Floor = "1" }, new Room { RoomID = 2, RoomTypeID = 2, RoomBandID = 2, RoomPriceID = 2, Floor = "2" }, new Room { RoomID = 3, RoomTypeID = 3, RoomBandID = 3, RoomPriceID = 3, Floor = "3" } }; foreach (Room y in Room) { context.Rooms.Add(y); } context.SaveChanges(); //RoomFacilitieList var RoomFacilitieList = new RoomFacilitieList[] { new RoomFacilitieList { FacilityID = 1, RoomID = 1, FacilityDetails = "Instalacion grifo" }, new RoomFacilitieList { FacilityID = 2, RoomID = 2, FacilityDetails = "Regadera" }, new RoomFacilitieList { FacilityID = 3, RoomID = 3, FacilityDetails = "Cama" } }; foreach (RoomFacilitieList w in RoomFacilitieList) { context.RoomFacilitieLists.Add(w); } context.SaveChanges(); //PaymentMethod var PaymentMethod = new PaymentMethod[] { new PaymentMethod { PaymentMethodID = 1, PaymentMethods = "Paypal" }, new PaymentMethod { PaymentMethodID = 2, PaymentMethods = "Cheque" }, new PaymentMethod { PaymentMethodID = 3, PaymentMethods = "Efectivo" } }; foreach (PaymentMethod o in PaymentMethod) { context.PaymentMethods.Add(o); } context.SaveChanges(); //Booking var Booking = new Booking[] { new Booking { BookingID = 1, CustomerID = 1, DateBookingMade = DateTime.Parse("1/1/2019"), TimeBookingMade = "dos dias", BookedStartDate = DateTime.Parse("29/2/2019"), BookedEndDate = DateTime.Parse("8/2/2019"), TotalPaymentDueAmount = 200, TotalPaymentDueDate = DateTime.Parse("1/3/2019"), BookingComments = "Sin comentarios" }, new Booking { BookingID = 2, CustomerID = 2, DateBookingMade = DateTime.Parse("2/2/2019"), TimeBookingMade = "dos dias", BookedStartDate = DateTime.Parse("4/2/2019"), BookedEndDate = DateTime.Parse("12/3/2019"), TotalPaymentDueAmount = 400, TotalPaymentDueDate = DateTime.Parse("11/12/2019"), BookingComments = "Sin comentarios" }, new Booking { BookingID = 3, CustomerID = 3, DateBookingMade = DateTime.Parse("2/3/2019"), TimeBookingMade = "tres dias", BookedStartDate = DateTime.Parse("5/2/2019"), BookedEndDate = DateTime.Parse("10/11/2019"), TotalPaymentDueAmount = 600, TotalPaymentDueDate = DateTime.Parse("4/10/2019"), BookingComments = "Sin comentarios" } }; foreach (Booking p in Booking) { context.Bookings.Add(p); } context.SaveChanges(); //Payment var Payment = new Payment[] { new Payment { PaymentID = 1, BookingID = 1, CustomerID = 1, PaymentMethodID = 1, PaymentAmount = 200, PaymentComments = "Sin comentario" }, new Payment { PaymentID = 2, BookingID = 2, CustomerID = 2, PaymentMethodID = 2, PaymentAmount = 300, PaymentComments = "Sin comentario" }, new Payment { PaymentID = 3, BookingID = 3, CustomerID = 3, PaymentMethodID = 3, PaymentAmount = 200, PaymentComments = "Sin comentario" } }; foreach (Payment a in Payment) { context.Payments.Add(a); } context.SaveChanges(); //Bookings Room var BookingRoom = new BookingRoom [] { new BookingRoom { BookingID = 1, RoomID = 1, GuestID = 1 }, new BookingRoom { BookingID = 2, RoomID = 2, GuestID = 2 }, new BookingRoom { BookingID = 3, RoomID = 3, GuestID = 3 } }; foreach (BookingRoom s in BookingRoom) { context.BookingRooms.Add(s); } context.SaveChanges(); }
public static void Initialize(HotelContext context) { context.Database.EnsureCreated(); // Look for any customers. if (context.Customers.Any()) { return; // DB has been seeded } //Customers var customers = new Customer[] { new Customer { CustomerTitle = "Ing.", CustomerForenames = "Alejandro", CustomerSurnames = "Garcia Cortes", CustomerDOB = DateTime.Parse("1995-03-11"), CustomerAddressStreet = "Monterrey 24", CustomerAddressTown = "Zacatecas", CustomerAddressCounty = "Guadalupe", CustomerAddressPostalCode = "98615", CustomerHomePhone = "492 926 5614", CustomerWorkPhone = null, CustomerMobilePhone = "492 650 8190", CustomerEmail = "*****@*****.**" }, new Customer { CustomerTitle = "Lic.", CustomerForenames = "Diana", CustomerSurnames = "Escareño Luna", CustomerDOB = DateTime.Parse("1993-11-20"), CustomerAddressStreet = "Fuentes 51", CustomerAddressTown = "Aguascalientes", CustomerAddressCounty = "Aguascalientes", CustomerAddressPostalCode = "97995", CustomerHomePhone = "449 443 8096", CustomerWorkPhone = "449 162 9831", CustomerMobilePhone = "449 210 8716", CustomerEmail = "*****@*****.**" }, new Customer { CustomerTitle = "Ing.", CustomerForenames = "Carlos", CustomerSurnames = "Gonzalez Beltran", CustomerDOB = DateTime.Parse("1980-01-10"), CustomerAddressStreet = "Gardenias 14", CustomerAddressTown = "Zacatecas", CustomerAddressCounty = "Fresnillo", CustomerAddressPostalCode = "96005", CustomerHomePhone = "493 102 6176", CustomerWorkPhone = null, CustomerMobilePhone = "493 110 7685", CustomerEmail = "*****@*****.**" }, new Customer { CustomerTitle = "Dr.", CustomerForenames = "Celina", CustomerSurnames = "Reyes Delgado", CustomerDOB = DateTime.Parse("1987-08-12"), CustomerAddressStreet = "12Octubre 56", CustomerAddressTown = "Zacatecas", CustomerAddressCounty = "Guadalupe", CustomerAddressPostalCode = "98618", CustomerHomePhone = "492 187 7726", CustomerWorkPhone = "492 901 7165", CustomerMobilePhone = "492 173 7862", CustomerEmail = null } }; foreach (Customer ia in customers) { context.Customers.Add(ia); } context.SaveChanges(); //Guest var guests = new Guest[] { new Guest { GuestTitle = "Ing.", GuestForenames = "Alejandro", GuestSurnames = "Garcia Cortes", GuestDOB = DateTime.Parse("1995-03-11"), GuestAddressStreet = "Monterrey 24", GuestAddressTown = "Zacatecas", GuestAddressCounty = "Guadalupe", GuestAddressPostalCode = "98615", GuestContactPhone = "492 650 8190" }, new Guest { GuestTitle = "Sra.", GuestForenames = "Martha", GuestSurnames = "Escareño Perez", GuestDOB = DateTime.Parse("1991-06-01"), GuestAddressStreet = "Gonzales Ortega 113", GuestAddressTown = "Zacatecas", GuestAddressCounty = "Guadalupe", GuestAddressPostalCode = "98256", GuestContactPhone = "492 662 5410" }, new Guest { GuestTitle = "Sr.", GuestForenames = "Ernesto", GuestSurnames = "Baez Beltran", GuestDOB = DateTime.Parse("1979-12-28"), GuestAddressStreet = "Condesa 23", GuestAddressTown = "Zacatecas", GuestAddressCounty = "Fresnillo", GuestAddressPostalCode = "96700", GuestContactPhone = "493 675 1273" }, new Guest { GuestTitle = "Dr.", GuestForenames = "Celina", GuestSurnames = "Reyes Delgado", GuestDOB = DateTime.Parse("1987-08-12"), GuestAddressStreet = "12Octubre 56", GuestAddressTown = "Zacatecas", GuestAddressCounty = "Guadalupe", GuestAddressPostalCode = "98618", GuestContactPhone = "492 173 7862" } }; foreach (Guest ib in guests) { context.Guests.Add(ib); } context.SaveChanges(); //Booking var bookings = new Booking[] { new Booking { DateBookingMade = DateTime.Parse("2019-10-01"), TimeBookingMade = DateTime.Parse("11:02:13"), BookedStartDate = DateTime.Parse("2019-10-11"), BookedEndDate = DateTime.Parse("2019-10-21"), TotalPaymentDueDate = DateTime.Parse("2019-11-11"), TotalPaymentDueAmount = 300, TotalPaymentMadeOn = DateTime.Parse("2019-10-30"), BookingComments = null, CustomerID = customers.Single(c => c.CustomerForenames == "Alejandro").CustomerID }, new Booking { DateBookingMade = DateTime.Parse("2019-12-22"), TimeBookingMade = DateTime.Parse("09:12:43"), BookedStartDate = DateTime.Parse("2019-12-25"), BookedEndDate = DateTime.Parse("2020-01-07"), TotalPaymentDueDate = DateTime.Parse("2020-01-25"), TotalPaymentDueAmount = 0, TotalPaymentMadeOn = DateTime.Parse("2019-12-22"), BookingComments = "La reservacion se pago el dia que fue realizada", CustomerID = customers.Single(c => c.CustomerForenames == "Diana").CustomerID }, new Booking { DateBookingMade = DateTime.Parse("2020-02-14"), TimeBookingMade = DateTime.Parse("08:32:13"), BookedStartDate = DateTime.Parse("2020-03-03"), BookedEndDate = DateTime.Parse("2020-03-15"), TotalPaymentDueDate = DateTime.Parse("2020-04-03"), TotalPaymentDueAmount = 700, TotalPaymentMadeOn = DateTime.Parse("2020-03-03"), BookingComments = "La reservacion se pago el dia que finalizo", CustomerID = customers.Single(c => c.CustomerForenames == "Carlos").CustomerID }, new Booking { DateBookingMade = DateTime.Parse("2020-04-23"), TimeBookingMade = DateTime.Parse("12:47:53"), BookedStartDate = DateTime.Parse("2020-04-30"), BookedEndDate = DateTime.Parse("2020-05-08"), TotalPaymentDueDate = DateTime.Parse("2020-05-30"), TotalPaymentDueAmount = 500, TotalPaymentMadeOn = DateTime.Parse("2020-05-13"), BookingComments = null, CustomerID = customers.Single(c => c.CustomerForenames == "Celina").CustomerID } }; foreach (Booking ic in bookings) { context.Bookings.Add(ic); } context.SaveChanges(); //RoomType var roomtypes = new RoomType[] { new RoomType { roomType = roomType.Individual }, new RoomType { roomType = roomType.Doble }, new RoomType { roomType = roomType.Cuadruple }, new RoomType { roomType = roomType.JuniorSuite }, new RoomType { roomType = roomType.Suite }, new RoomType { roomType = roomType.GranSuite } }; foreach (RoomType id in roomtypes) { context.RoomTypes.Add(id); } context.SaveChanges(); //RoomBand var roombands = new RoomBand[] { new RoomBand { BandDesc = "A" }, new RoomBand { BandDesc = "AA" }, new RoomBand { BandDesc = "AAA" }, new RoomBand { BandDesc = "AAAA" }, new RoomBand { BandDesc = "AAAAA" } }; foreach (RoomBand ie in roombands) { context.RoomBands.Add(ie); } context.SaveChanges(); //RoomPrice var roomprices = new RoomPrice[] { new RoomPrice { roomPrice = 500 }, new RoomPrice { roomPrice = 1000 }, new RoomPrice { roomPrice = 1800 }, new RoomPrice { roomPrice = 2000 }, new RoomPrice { roomPrice = 2400 } }; foreach (RoomPrice ig in roomprices) { context.RoomPrices.Add(ig); } context.SaveChanges(); //Room var rooms = new Room[] { new Room { Floor = "2", AdditionalNotes = "Habitacion: Individual - Precio: $500 por dia", RoomTypeID = roomtypes.Single(c => c.roomType == roomType.Individual).RoomTypeID, RoomBandID = roombands.Single(i => i.BandDesc == "A").RoomBandID, RoomPriceID = roomprices.Single(s => s.roomPrice == 500).RoomPriceID }, new Room { Floor = "3", AdditionalNotes = "Habitacion: Doble - Precio: $1000 por dia", RoomTypeID = roomtypes.Single(c => c.roomType == roomType.Doble).RoomTypeID, RoomBandID = roombands.Single(i => i.BandDesc == "AA").RoomBandID, RoomPriceID = roomprices.Single(s => s.roomPrice == 1000).RoomPriceID }, new Room { Floor = "4", AdditionalNotes = "Habitacion: Cuadruple - Precio: $1800 por dia", RoomTypeID = roomtypes.Single(c => c.roomType == roomType.Cuadruple).RoomTypeID, RoomBandID = roombands.Single(i => i.BandDesc == "AAAA").RoomBandID, RoomPriceID = roomprices.Single(s => s.roomPrice == 1800).RoomPriceID }, new Room { Floor = "6", AdditionalNotes = "Habitacion: Suite - Precio: $2400 por dia", RoomTypeID = roomtypes.Single(c => c.roomType == roomType.Suite).RoomTypeID, RoomBandID = roombands.Single(i => i.BandDesc == "AAAAA").RoomBandID, RoomPriceID = roomprices.Single(s => s.roomPrice == 2400).RoomPriceID } }; foreach (Room ih in rooms) { context.Rooms.Add(ih); } context.SaveChanges(); //BookingRoom var bookingsrooms = new BookingRoom[] { new BookingRoom { BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2019-10-01")).BookingID, RoomID = rooms.Single(i => i.Floor == "2").RoomID, GuestID = guests.Single(s => s.GuestForenames == "Alejandro").GuestID }, new BookingRoom { BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2019-12-22")).BookingID, RoomID = rooms.Single(i => i.Floor == "3").RoomID, GuestID = guests.Single(s => s.GuestForenames == "Martha").GuestID }, new BookingRoom { BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2020-02-14")).BookingID, RoomID = rooms.Single(i => i.Floor == "4").RoomID, GuestID = guests.Single(s => s.GuestForenames == "Ernesto").GuestID }, new BookingRoom { BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2020-04-23")).BookingID, RoomID = rooms.Single(i => i.Floor == "6").RoomID, GuestID = guests.Single(s => s.GuestForenames == "Celina").GuestID } }; foreach (BookingRoom i in bookingsrooms) { context.BookingsRooms.Add(i); } context.SaveChanges(); foreach (BookingRoom ix in bookingsrooms) { var bookingroomInDataBase = context.BookingsRooms.Where( z => z.Booking.BookingID == ix.BookingID && z.Room.RoomID == ix.RoomID && z.Guest.GuestID == ix.GuestID).SingleOrDefault(); if (bookingroomInDataBase == null) { context.BookingsRooms.Add(ix); } } context.SaveChanges(); //PaymentMethod var paymentmethods = new PaymentMethod[] { new PaymentMethod { paymentMethod = "Efectivo" }, new PaymentMethod { paymentMethod = "Tarjeta de Credito o Debito" }, new PaymentMethod { paymentMethod = "Transferencia Bancaria" }, new PaymentMethod { paymentMethod = "Paypal" } }; foreach (PaymentMethod ip in paymentmethods) { context.PaymentMethods.Add(ip); } context.SaveChanges(); //Payment var payments = new Payment[] { new Payment { PaymentAmount = 6000, PaymentComments = "Pago saldado totalmente", BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2019-10-01")).BookingID, CustomerID = customers.Single(i => i.CustomerForenames == "Alejandro").CustomerID, PaymentMethodID = paymentmethods.Single(s => s.paymentMethod == "Efectivo").PaymentMethodID }, new Payment { PaymentAmount = 5000, PaymentComments = "Pago saldado totalmente", BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2019-12-22")).BookingID, CustomerID = customers.Single(i => i.CustomerForenames == "Diana").CustomerID, PaymentMethodID = paymentmethods.Single(s => s.paymentMethod == "Transferencia Bancaria").PaymentMethodID }, new Payment { PaymentAmount = 10000, PaymentComments = "Pago saldado parcialmente", BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2020-02-14")).BookingID, CustomerID = customers.Single(i => i.CustomerForenames == "Carlos").CustomerID, PaymentMethodID = paymentmethods.Single(s => s.paymentMethod == "Efectivo").PaymentMethodID }, new Payment { PaymentAmount = 6000, PaymentComments = "Pago saldado totalmente", BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2020-04-23")).BookingID, CustomerID = customers.Single(i => i.CustomerForenames == "Celina").CustomerID, PaymentMethodID = paymentmethods.Single(s => s.paymentMethod == "Paypal").PaymentMethodID } }; foreach (Payment iq in payments) { context.Payments.Add(iq); } context.SaveChanges(); //FacilitieList var facilitielists = new FacilitieList[] { new FacilitieList { FacilityDesc = "(1)Cama individual - (1)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Otros muebles" }, new FacilitieList { FacilityDesc = "(2)Cama individual - (1)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles" }, new FacilitieList { FacilityDesc = "(4)Cama individual - (2)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles" }, new FacilitieList { FacilityDesc = "(2)Cama matrimonial - (2)TV - Telefono - (1)Computadora - Refrigerador - Microondas - Internet - Cafetera - Plancha - Jacuzzi - Otros muebles" }, new FacilitieList { FacilityDesc = "(2)Cama matrimonial - (1)TV - Telefono - (1)Computadora- Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles" }, new FacilitieList { FacilityDesc = "(2)Cama king-size - (2)TV - Telefono - (2)Computadora - Refrigerador - Microondas - Internet - Cafetera - Plancha, Jacuzzi - Alberca - Otros muebles" } }; foreach (FacilitieList io in facilitielists) { context.FacilitieLists.Add(io); } context.SaveChanges(); //RoomFacilities var roomsfacilities = new RoomFacilities[] { new RoomFacilities { FacilityDetails = "Incluye servicios basicos", RoomID = rooms.Single(c => c.Floor == "2").RoomID, FacilityID = facilitielists.Single(s => s.FacilityDesc == "(1)Cama individual - (1)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Otros muebles").FacilityID, }, new RoomFacilities { FacilityDetails = "Incluye servicios basicos", RoomID = rooms.Single(c => c.Floor == "3").RoomID, FacilityID = facilitielists.Single(s => s.FacilityDesc == "(2)Cama individual - (1)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles").FacilityID, }, new RoomFacilities { FacilityDetails = "Incluye servicios basicos + extra", RoomID = rooms.Single(c => c.Floor == "4").RoomID, FacilityID = facilitielists.Single(s => s.FacilityDesc == "(4)Cama individual - (2)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles").FacilityID, }, new RoomFacilities { FacilityDetails = "Incluye servicios basicos + extra", RoomID = rooms.Single(c => c.Floor == "6").RoomID, FacilityID = facilitielists.Single(s => s.FacilityDesc == "(2)Cama matrimonial - (2)TV - Telefono - (1)Computadora - Refrigerador - Microondas - Internet - Cafetera - Plancha - Jacuzzi - Otros muebles").FacilityID } }; foreach (RoomFacilities im in roomsfacilities) { context.RoomsFacilities.Add(im); } context.SaveChanges(); foreach (RoomFacilities ir in roomsfacilities) { var roomfacilitiesInDataBase = context.RoomsFacilities.Where( w => w.Room.RoomID == ir.RoomID && w.FacilitieList.FacilityID == ir.FacilityID).SingleOrDefault(); if (roomfacilitiesInDataBase == null) { context.RoomsFacilities.Add(ir); } } context.SaveChanges(); }
public double GetSingleRoomPrice(IList <BookedRoom> lSingleRoom, Cruise cruise, SailsTrip trip) { var lRoomPrice = new List <RoomPrice>(); var roomPrice1 = new RoomPrice() { Cruise = NSession.QueryOver <Cruise>().Where(x => x.Id == 1).SingleOrDefault(), RoomClass = NSession.QueryOver <RoomClass>().Where(x => x.Id == 1).SingleOrDefault(), RoomType = NSession.QueryOver <RoomTypex>().Where(x => x.Id == 2).SingleOrDefault(), Trip = NSession.QueryOver <SailsTrip>().Where(x => x.Id == 2).SingleOrDefault(), SingleRoom = true, Price = 10, };//os hl2d deluxe double var roomPrice2 = new RoomPrice() { Cruise = NSession.QueryOver <Cruise>().Where(x => x.Id == 1).SingleOrDefault(), RoomClass = NSession.QueryOver <RoomClass>().Where(x => x.Id == 1).SingleOrDefault(), RoomType = NSession.QueryOver <RoomTypex>().Where(x => x.Id == 3).SingleOrDefault(), Trip = NSession.QueryOver <SailsTrip>().Where(x => x.Id == 2).SingleOrDefault(), SingleRoom = true, Price = 30, };//os hl2d deluxe twwin var roomPrice3 = new RoomPrice() { Cruise = NSession.QueryOver <Cruise>().Where(x => x.Id == 3).SingleOrDefault(), RoomClass = NSession.QueryOver <RoomClass>().Where(x => x.Id == 1).SingleOrDefault(), RoomType = NSession.QueryOver <RoomTypex>().Where(x => x.Id == 2).SingleOrDefault(), Trip = NSession.QueryOver <SailsTrip>().Where(x => x.Id == 2).SingleOrDefault(), SingleRoom = true, Price = 200, }; //os2 hl2d deluxe double var roomPrice4 = new RoomPrice() { Cruise = NSession.QueryOver <Cruise>().Where(x => x.Id == 3).SingleOrDefault(), RoomClass = NSession.QueryOver <RoomClass>().Where(x => x.Id == 1).SingleOrDefault(), RoomType = NSession.QueryOver <RoomTypex>().Where(x => x.Id == 3).SingleOrDefault(), Trip = NSession.QueryOver <SailsTrip>().Where(x => x.Id == 2).SingleOrDefault(), SingleRoom = true, Price = 10, }; //os2 hl2d deluxe twin var roomPrice5 = new RoomPrice() { Cruise = NSession.QueryOver <Cruise>().Where(x => x.Id == 3).SingleOrDefault(), RoomClass = NSession.QueryOver <RoomClass>().Where(x => x.Id == 1).SingleOrDefault(), RoomType = NSession.QueryOver <RoomTypex>().Where(x => x.Id == 7).SingleOrDefault(), Trip = NSession.QueryOver <SailsTrip>().Where(x => x.Id == 2).SingleOrDefault(), SingleRoom = true, Price = 320, }; //os2 hl2d deluxe triple lRoomPrice.Add(roomPrice1); lRoomPrice.Add(roomPrice2); lRoomPrice.Add(roomPrice3); lRoomPrice.Add(roomPrice4); lRoomPrice.Add(roomPrice5); lRoomPrice = lRoomPrice.Where(x => x.Cruise == cruise && x.Trip == trip).ToList(); double allRoomPrice = 0.0; foreach (var singleRoom in lSingleRoom) { foreach (var roomPrice in lRoomPrice) { if (singleRoom.RoomClass == roomPrice.RoomClass && singleRoom.RoomType == roomPrice.RoomType) { allRoomPrice = allRoomPrice + roomPrice.Price * singleRoom.Quantity; } } } return(allRoomPrice); }