public CustomerInfo GetCustomerInfo(EntityRef <Customer> customer, bool getAllRentals) { if (customer.IsNull) { throw new ArgumentNullException("customer"); } CustomerInfo customerInfo = new CustomerInfo { Customer = customer.GetVanillaEntity(), Rentals = new List <RentalInfo>() }; foreach (Rental rental in StorageContext.Current.Find <Rental>(candidate => candidate.Customer == customer && (getAllRentals || !candidate.Closed))) { RentalInfo rentalInfo = new RentalInfo(); rentalInfo.Book = rental.Book.Entity; rentalInfo.Rental = rental; rentalInfo.Notes = new List <Note>(StorageContext.Current.Find <Note>(candidate => candidate.Owner == rental)); customerInfo.Rentals.Add(rentalInfo); } customerInfo.AccountLines = new List <CustomerAccountLine>(StorageContext.Current.Find <CustomerAccountLine>( candidate => candidate.Customer == customer)); return(customerInfo); }
protected void Submit_Click(object sender, EventArgs e) { //when submit mark equipmnet as not avalible in rental details where rental details rentalid == rentalID if (CreditCardTextbox != null && RentalID != null) { int couponID = int.Parse(CouponID.Text); int creditcard = int.Parse(CreditCardTextbox.Text); MessageUserControl.TryRun(() => { RentalController sysmgr = new RentalController(); RentalInfo rentalinfo = new RentalInfo(); MessageUserControl.ShowInfo(rentalinfo.EmployeeID.ToString()); //RentalDetail details = new RentalDetail(); //update rental where rentalID = rentalID add coupon and creditcard }, "Completed Rental", "The rental has been created"); } else { MessageUserControl.ShowInfo("Credit Card Is Required", "Please enter a credit card number to complete the rental"); } }
public RentedMoviesResponseJSON getUserRentals(int userId) { RentedMoviesResponseJSON res = new RentedMoviesResponseJSON(); using (MovieEntities db = new MovieEntities()) { var rental = (from u in db.UsersRentals join m in db.Movies on u.Movies_ID equals m.Movies_ID join p in db.MoviesRentalPrices on m.Movies_ID equals p.Movies_ID where u.Users_ID == userId select new { UserId = u.Users_ID, movieTitle = m.Title, rentaldatefrom = u.RentalDateFrom, rentaldateto = u.RentalDateTo, price = p.Price }).ToList(); List <RentalInfo> lstrentals = new List <RentalInfo>(); foreach (var item in rental) { RentalInfo ri = new RentalInfo(); if (item.rentaldatefrom.HasValue) { ri.rentaldatefrom = item.rentaldatefrom.Value.ToShortDateString(); } if (item.rentaldateto.HasValue) { ri.rentaldateto = item.rentaldateto.Value.ToShortDateString(); } ri.title = item.movieTitle; if (item.price.HasValue) { ri.price = item.price.Value; } lstrentals.Add(ri); } res.rentals = lstrentals; return(res); } }
public IHttpActionResult CreateMovieRental(MovieRentalDto movieRental) { var customer = _db.Customers.SingleOrDefault(c => c.Id == movieRental.CustomerId); if (customer == null) { return(BadRequest("Invalid CustomerId")); } if (movieRental.MovieIds.Count == 0) { return(BadRequest("No movies selected")); } var movies = _db.Movies.Where(m => movieRental.MovieIds.Contains(m.Id)).ToList(); if (movieRental.MovieIds.Count != movies.Count) { BadRequest("One or more invalid MovieIds"); } foreach (var movie in movies) { if (movie.QuantityAvailable == 0) { BadRequest("Movie is out of stock"); } --movie.QuantityAvailable; var movieToRent = new RentalInfo { Customer = customer, Movie = movie, DateRented = DateTime.Now }; _db.RentalInfos.Add(movieToRent); } _db.SaveChanges(); return(Ok()); }
public Booking(Guid id, DateTime pickUpDate, DateTime dropOffDate, string pickUpLocation, string dropOffLocation, string clientRequestInfo, Car carToBook, RentalInfo rentalInfo) => (Id, PickUpDate, DropOffDate, PickUpLocation,
/// <summary> /// SubmitRental /// </summary> /// <param name="basic"></param> /// <param name="rent"></param> /// <returns></returns> public Tuple <APIMethodControl, RentalInfo> SubmitRental(BasicStructure basic, Rental_PS rent) { using (var context = WebAPIManagerFactory.CreateContext(ip7913, port7913, _logfile)) { var info = new RentalInfo(); var apc = new APIMethodControl(); var temp = FillBasic(basic); temp.Add(rent.locationId.ToString()); temp.Add(rent.returnLocationId.ToString()); temp.Add(rent.productId.ToString()); temp.Add(rent.pickupDate); temp.Add(rent.pickupTime); temp.Add(rent.returnDate); temp.Add(rent.returnTime); temp.Add(rent.categoryId.ToString()); temp.Add(rent.coRenterName.ToString()); temp.Add(rent.coRenterSurName.ToString()); temp.Add(rent.coRenterLicenseNo.ToString()); temp.Add(rent.coRenterBirthDay.ToString()); temp.Add(rent.rekvisitionNo.ToString()); temp.Add(rent.payType.ToString()); for (int i = 0; i < 10; i++) { try { temp.Add(rent.drivers[i].ToString()); } catch { temp.Add(""); } } temp.Add(rent.bookStatus.ToString()); temp.Add(rent.renterName.ToString()); temp.Add(rent.renterBirthDay.ToString()); temp.Add(rent.renterAddress.ToString()); temp.Add(rent.renterZipCity.ToString()); temp.Add(rent.renterPhone.ToString()); temp.Add(rent.renterEmail.ToString()); foreach (ExtraProduct ep in rent.extras) { temp.Add(ep.id.ToString()); temp.Add(ep.numbUnit.ToString()); } var str = Helpers.EncodeString(temp.ToArray()); var text = context.GetData(str); var keys = Helpers.DecodeString(text); if (keys[0].ToLower() == errorstring) { apc.Succes = false; apc.ErrorCode = keys[1]; apc.ErrorMessage = keys[2]; } else { apc.Succes = true; info.ReservationNo = keys[0]; info.TotalPrice = keys[1]; info.DepositOnline = keys[2]; info.DepositPickupCash = keys[3]; info.DepositPickupCard = keys[4]; info.RentPlusDepositOnline = keys[5]; info.RentPlusDepositPickupCash = keys[6]; info.RentPlusDepositPickupCard = keys[7]; info.AddOnsTotalPrice = keys[8]; info.TotalPriceExclAddOnsTotalPrice = keys[9]; } return(Tuple.Create(apc, info)); } }