Beispiel #1
0
 public void DeleteCarType(int carTypeId)
 {
     //unitOfWork.StartTransaction();
     CarTypeRepository repo = new CarTypeRepository(unitOfWork);
     repo.Delete(x => x.CarTypeId == carTypeId);
     //unitOfWork.Commit();
 }
Beispiel #2
0
        public void CanGetAllCarType()
        {
            var repo = new CarTypeRepository();

            Assert.AreEqual(2, repo.GetAll().Count);
            Assert.AreEqual("Used", repo.GetAll().FirstOrDefault().CarTypeName);
        }
Beispiel #3
0
        public void CanRemoveCarType()
        {
            var repo = new CarTypeRepository();

            Assert.AreEqual(2, repo.GetAll().Count);
            repo.Remove(1);
            Assert.AreEqual(1, repo.GetAll().Count);
        }
Beispiel #4
0
 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;
 }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 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;
 }
Beispiel #7
0
 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;
 }
Beispiel #8
0
 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;
     }
 }
Beispiel #9
0
        public void CanGetCarType()
        {
            CarTypeRepository repo = new CarTypeRepository();

            Assert.AreEqual("Used", repo.Get(1).CarTypeName);
        }