public HomeController(CarsLogic carsLogic, SalonsLogic salonsLogic, RentersLogic rentersLogic, StatsLogic statsLogic) { this.carsLogic = carsLogic; this.salonsLogic = salonsLogic; this.rentersLogic = rentersLogic; this.statsLogic = statsLogic; }
public int AddReservation(int carFleetID, int userID, DateTime startDate, DateTime desiredEndDate) { CarsLogic cars = new CarsLogic(); return(cars.AddReservation(carFleetID, userID, startDate, desiredEndDate)); }
public void TestGetAllCars() { Mock <IRepository <Cars> > mockedRepo = new Mock <IRepository <Cars> > (MockBehavior.Loose); List <Cars> cars = new List <Cars> { new Cars() { Make = "Audi", Model = "A5" }, new Cars() { Make = "Ford", Model = "Mondeo" }, new Cars() { Make = "Suzuki", Model = "Swift" }, new Cars() { Make = "VW", Model = "Transporter" } }; List <Cars> expectedCars = new List <Cars>() { new Cars() { Make = "Audi", Model = "A5" }, new Cars() { Make = "Ford", Model = "Mondeo" }, new Cars() { Make = "Suzuki", Model = "Swift" }, new Cars() { Make = "VW", Model = "Transporter" } }; mockedRepo.Setup(repo => repo.Print()).Returns(cars.AsQueryable()); CarsLogic logic = new CarsLogic(mockedRepo.Object); //Act var result = logic.PrintCars(); //Assert Assert.That(result.Count, Is.EqualTo(expectedCars.Count)); Assert.That(result, Is.EquivalentTo(expectedCars)); //Verify mockedRepo.Verify(repo => repo.Print(), Times.Once); }
//method returns chosen car by selected type from select tag public IQueryable <CarInventory> GetCarByCategory(string CarTypeName) { using (CarsLogic carsByCategory = new CarsLogic()) { return(carsByCategory.CarByCategory(CarTypeName).AsQueryable()); //return from x in dal.CarInventories // where x.CarTypeName.Contains(CarTypeName) // select x; } }
public int UpdateCarFleet(int carFleetID, string carNumber, int currentMiles, string imageFileName, bool isOK2Rent, int carTypeID, int carModelID, int year, int gearTypeID, int dailyCost, int dailyLateCost, int carManufactureID, string carModelName, string carManufactureName) { CarsLogic cars = new CarsLogic(); return(cars.UpdateCarFleet(carFleetID, carNumber, currentMiles, imageFileName, isOK2Rent, carTypeID, carModelID, year, gearTypeID, dailyCost, dailyLateCost, carManufactureID, carModelName, carManufactureName)); }
public IHttpActionResult ReturnCar(int RentalID, DateTime actualEndDate) { CarsLogic cars = new CarsLogic(); var results = cars.ReturnCar(RentalID, actualEndDate); if (results == 0) { return(NotFound()); } return(Ok(results)); }
//method : returns car details by car ID (number) public CarInventory GetChosenCar(int CarID) // the methoda is called because its named Get... and by the call from the JQuery { //using (RentCarEntities dal=new RentCarEntities()) //{ // return dal.carinventories.ToList(); //} using (CarsLogic carsfromdb = new CarsLogic()) { return(carsfromdb.ChosenCar(CarID)); } }
//not working yet brcause of date type public IQueryable <CarInventory> postneworder(string carType, DateTime dateIn, DateTime dateOut) { using (CarsLogic availableCars = new CarsLogic()) { string cType = carType; DateTime In = dateIn; DateTime Out = dateOut; return(availableCars.AvailableCars(dateIn, dateOut).AsQueryable()); //return from x in dal.CarInventories // where x.CarTypeName.Contains(CarTypeName) // select x; } }
public IHttpActionResult DeleteCarFleet(int carFleetID) { CarsLogic cars = new CarsLogic(); var result = cars.DeleteCarFleet(carFleetID); if (result == 1)//there are no orders for this carID { return(Ok(result)); } else { return(NotFound()); } }
// not working yet public IQueryable <CarInventory> PostAvailableCars(DateTime dateIn, DateTime dateOut) { using (CarsLogic availableCars = new CarsLogic()) { //DateTime parsedIn = DateTime.Parse(dateIn); //DateTime parsedOut = DateTime.Parse(dateOut); DateTime parsedIn = dateIn; DateTime parsedOut = dateOut; return(availableCars.AvailableCars(parsedIn, parsedOut).AsQueryable()); //return from x in dal.CarInventories // where x.CarTypeName.Contains(CarTypeName) // select x; } }
public IHttpActionResult AddCar(string carNumber, int currentMiles, string imageFileName, bool isOK2Rent, int carModelID, int year, int gearTypeID, int dailyCost, int dailyLateCost) { CarsLogic cars = new CarsLogic(); var result = cars.AddCar(carNumber, currentMiles, imageFileName, isOK2Rent, carModelID, year, gearTypeID, dailyCost, dailyLateCost); if (result == 2) { return(Ok(result)); } else { return(NotFound()); } }
public void TestGetOneCar() { Mock <IRepository <Cars> > mockedRepo = new Mock <IRepository <Cars> >(); List <Cars> cars = new List <Cars> { new Cars() { CarId = Guid.NewGuid().ToString(), Make = "Audi", Model = "A5" }, new Cars() { CarId = Guid.NewGuid().ToString(), Make = "Ford", Model = "Mondeo" }, new Cars() { CarId = Guid.NewGuid().ToString(), Make = "Suzuki", Model = "Swift" }, new Cars() { CarId = Guid.NewGuid().ToString(), Make = "VW", Model = "Transporter" } }; Cars expectedCar = new Cars() { CarId = Guid.NewGuid().ToString(), Make = "Suzuki", Model = "Swift" }; mockedRepo.Setup(repo => repo.GetOneObj(cars[2].CarId)).Returns(expectedCar); CarsLogic logic = new CarsLogic(mockedRepo.Object); var result = logic.GetOneCar(cars[2].CarId); Assert.That(result, Is.EqualTo(expectedCar)); mockedRepo.Verify(repo => repo.GetOneObj(cars[2].CarId), Times.Once); }
//get all the cars that are ok to rent between startDate and endDate public IEnumerable GetAllCars(DateTime startDate, DateTime endDate) { CarsLogic cars = new CarsLogic(); return(cars.GetAllCars(startDate, endDate)); }
public IEnumerable GetAllGearTypes() { CarsLogic cars = new CarsLogic(); return(cars.GetAllGearTypes()); }
public IEnumerable GetAllCarsImages() { CarsLogic cars = new CarsLogic(); return(cars.GetAllCarImages()); }
public IEnumerable GetAllModelName() { CarsLogic cars = new CarsLogic(); return(cars.GetAllModelName()); }
public IEnumerable GetAllManufactureName() { CarsLogic cars = new CarsLogic(); return(cars.GetAllManufactureName()); }
public IEnumerable GetAllCarFleet() { CarsLogic cars = new CarsLogic(); return(cars.GetAllCarFleet()); }
public CarsController(CarsLogic carsLogic) { this.carsLogic = carsLogic; }
public OtherController(SalonsLogic sLogic, CarsLogic cLogic, RentersLogic rLogic) { this.sLogic = sLogic; this.cLogic = cLogic; this.rLogic = rLogic; }