public void DeleteCarType(int carTypeId) { //unitOfWork.StartTransaction(); CarTypeRepository repo = new CarTypeRepository(unitOfWork); repo.Delete(x => x.CarTypeId == carTypeId); //unitOfWork.Commit(); }
public void CanGetAllCarType() { var repo = new CarTypeRepository(); Assert.AreEqual(2, repo.GetAll().Count); Assert.AreEqual("Used", repo.GetAll().FirstOrDefault().CarTypeName); }
public void CanRemoveCarType() { var repo = new CarTypeRepository(); Assert.AreEqual(2, repo.GetAll().Count); repo.Remove(1); Assert.AreEqual(1, repo.GetAll().Count); }
public CarTypeModel SaveCarType(CarTypeModel model) { //unitOfWork.StartTransaction(); CarTypeRepository repo = new CarTypeRepository(unitOfWork); CarType carType = new CarType(); AutoMapper.Mapper.Map(model, carType); repo.Insert(carType); //unitOfWork.Commit(); AutoMapper.Mapper.Map(carType, model); return model; }
public void CanAddCarType() { var repo = new CarTypeRepository(); Assert.AreEqual(2, repo.GetAll().Count); repo.Add(new CarType() { CarTypeName = "Restored" }); Assert.AreEqual(3, repo.GetAll().Count); }
public CarTypeModel GetCarTypeById(int carTypeId) { //unitOfWork.StartTransaction(); CarTypeRepository repo = new CarTypeRepository(unitOfWork); CarTypeModel carTypeModel = new CarTypeModel(); CarType carType = new CarType(); AutoMapper.Mapper.Map(carTypeModel, carType); carType = repo.GetAll().Where(x => x.CarTypeId == carTypeId).FirstOrDefault(); //unitOfWork.Commit(); AutoMapper.Mapper.Map(carType, carTypeModel); return carTypeModel; }
public List<CarTypeModel> GetAllCarTypes() { //unitOfWork.StartTransaction(); CarTypeRepository repo = new CarTypeRepository(unitOfWork); List<CarTypeModel> carTypeModelList = new List<CarTypeModel>(); List<CarType> carTypeList = new List<CarType>(); AutoMapper.Mapper.Map(carTypeModelList, carTypeList); carTypeList = repo.GetAll().OrderByDescending(x=>x.CarTypeId).ToList(); //unitOfWork.Commit(); AutoMapper.Mapper.Map(carTypeList, carTypeModelList); return carTypeModelList; }
public bool CheckExistance(int carTypeId) { //unitOfWork.StartTransaction(); CarTypeRepository repo = new CarTypeRepository(unitOfWork); var city = repo.GetAll().Where(x => x.CarTypeId == carTypeId).Count(); //unitOfWork.Commit(); if (city > 0) { return true; } else { return false; } }
public void CanGetCarType() { CarTypeRepository repo = new CarTypeRepository(); Assert.AreEqual("Used", repo.Get(1).CarTypeName); }