public IHttpActionResult SubmitRental(Rental_PS rental) { var bs1 = fillbasics(); var bs = Mapper.Map <BasicStructure, NordCar.Carla.Data.Entities.BasicStructure>(bs1); var rent1 = Mapper.Map <Rental_PS, NordCar.Carla.Data.Entities.Rental_PS>(rental); var data = this.PSAPIManagerRepository.SubmitRental(bs, rent1); if (data.Item1.Succes) { return(Ok(Mapper.Map <NordCar.Carla.Data.Entities.RentalInfo, RentalInfo>(data.Item2))); } else { return(Error(Mapper.Map <NordCar.Carla.Data.Entities.APIMethodControl, APIMethodControl>(data.Item1), HttpStatusCode.NotFound)); } }
public void SubmitRental() { var drivers = new List <Driver2>(); drivers.Add(new Driver2() { name = "James-0" }); drivers.Add(new Driver2() { name = "James-1" }); drivers.Add(new Driver2() { name = "James-2" }); var extras = new List <ExtraProduct>(); extras.Add(new ExtraProduct() { id = 1, numbUnit = "1" }); extras.Add(new ExtraProduct() { id = 2, numbUnit = "2" }); extras.Add(new ExtraProduct() { id = 3, numbUnit = "3" }); var rental = new Rental_PS() { locationId = 53, returnLocationId = 53, productId = 1, pickupDate = convertDateTimeToCarlaDateTime(DateTime.Now.AddDays(1)), pickupTime = "0800", returnDate = convertDateTimeToCarlaDateTime(DateTime.Now.AddDays(1)), returnTime = "0700", categoryId = "A", coRenterName = "Bonnie", coRenterSurName = "Raith", coRenterLicenseNo = "012334560123456", coRenterBirthDay = "02021996", rekvisitionNo = "blank", payType = "1", drivers = drivers, bookStatus = "1", renterName = "Clyde Raith", renterBirthDay = "03051996", renterAddress = "Don Johnson Drive 12th", renterZipCity = "600 Miami", renterPhone = "00812563489", renterEmail = "*****@*****.**", extras = extras }; //Act var response = controller.SubmitRental(rental); //Assert Assert.IsNotNull(response); }
/// <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)); } }