public ActionResult Admin(int rentId, int res) { HttpResponseMessage response = client.GetAsync("api/rents/" + rentId).Result; Rentalinformation rent = response.Content.ReadAsAsync <Rentalinformation>().Result; if (res == 1) { Rentalinformation tempRent = new Rentalinformation() { CustomerID = rent.CustomerID, VehicleID = rent.VehicleID, HowManyDays = rent.HowManyDays, Id = rent.Id, IsRequest = rent.IsRequest, IsActive = rent.IsActive, LastKmId = rent.LastKmId, Payment = rent.Payment, StartKm = rent.StartKm }; RentModel model = new RentModel(); model.rent = tempRent; model.vehicleId = rent.VehicleID; model.customerId = rent.CustomerID; //kirala response = client.PostAsJsonAsync("api/vehicles/RentACar", model).Result; } else if (res == 0) { response = client.GetAsync("api/vehicles/UnRentACar?id=" + rent.Id).Result; } return(Redirect("/Login/Admin")); }
public Rentalinformation RentRequest(int TCNumber, int vehicleId, int howManyDays) { Customer customer = customerDal.Get(x => x.TCNumber == TCNumber); VehicleInformation vehicle = vehicleDal.Get(x => x.Id == vehicleId); Rentalinformation rental = new Rentalinformation(); rental.CustomerID = customer.Id; rental.VehicleID = vehicleId; rental.HowManyDays = howManyDays; rental.Payment = vehicle.DailyRentalPrice * howManyDays; rental.StartKm = vehicle.DailyBorderKm; rental.IsRequest = true; rental.IsActive = false; rentDal.Add(rental); return(rental); }
public bool UnRentACar(int rentId) { Rentalinformation rental = rentalDal.Get(x => x.Id == rentId); if (rental.IsRequest) { rental.CustomerID = 0; //istek reddedilirse aracın customeri sıfırla. } rental.IsActive = false; rental.IsRequest = false; rental.FinishDate = DateTime.Now; rentalDal.Update(rental); VehicleInformation vehicle = Get(rental.VehicleID); vehicle.CustomerID = 0; vehicle.isRentaled = false; vehicleDal.Update(vehicle); return(true); }
public bool RentACar(int vehicleId, int customerId, Rentalinformation rental) { VehicleInformation vehicle = Get(vehicleId); if (vehicle == null) { return(false); } rental.IsActive = true; rental.IsRequest = false; rental.StartDate = DateTime.Now; rentalDal.Update(rental); List <Rentalinformation> rents = rentalDal.GetList(x => x.Id != rental.Id && x.VehicleID == vehicle.Id); foreach (var rent in rents) { rent.IsActive = false; rent.IsRequest = false; rent.FinishDate = DateTime.Now; rentalDal.Update(rent); } Company company = companyDal.Get(x => x.Id == 1); company.Earning += rental.Payment; company.Expense -= (100 * rental.HowManyDays); companyDal.Update(company); vehicle.CustomerID = customerId; vehicle.isRentaled = true; vehicleDal.Update(vehicle); return(true); }
public Rentalinformation RentRequest(int TCNumber, int vehicleId, int howManyDays) { Rentalinformation rentalinformation = customerService.RentRequest(TCNumber, vehicleId, howManyDays); return(rentalinformation); }
public bool RentACar(int vehicleId, int customerId, Rentalinformation rental) { bool rentACar = VehicleService.RentACar(vehicleId, customerId, rental); return(rentACar); }
public Rentalinformation Get(int rentalId) { Rentalinformation rentalinformation = rentService.Get(rentalId); return(rentalinformation); }