public void GetCarDetailsTest() { Vehicle editCar = new Vehicle(); VehicleRepoEF repo = new VehicleRepoEF(); int id = 1; var getCar = _ctx.GetAllByCarId(id).FirstOrDefault(); editCar = VehicleData.Car(getCar); Assert.AreEqual(id, editCar.CarId); Assert.AreEqual(2012, editCar.Year); Assert.AreEqual(25000, editCar.Mileage); }
public CarView GetDetails(int carId) { var carDetails = new CarView(); using (_ctx) { var dbDetails = _ctx.GetAllByCarId(carId).FirstOrDefault(); if (!string.IsNullOrEmpty(dbDetails.ToString())) { carDetails = VehicleView.Car(dbDetails); } } return(carDetails); }
public Vehicle GetAllByCarId(int id) { Vehicle editCar = new Vehicle(); using (_ctx = new GuildCarsEntities()) { try { var getCar = _ctx.GetAllByCarId(id).FirstOrDefault(); editCar = VehicleData.Car(getCar); } catch (Exception ex) { throw ex; } } return(editCar); }