Exemple #1
0
 public void DeleteCity(int cityId)
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     repo.Delete(x => x.CityId == cityId);
     //unitOfWork.Commit();
 }
Exemple #2
0
        private void DropDownInit()
        {
            CategoryRepository catRep = new CategoryRepository();
            List<category> categList = catRep.Get().ToList();
            ViewBag.categories = new SelectList(categList, "categoryID", "name", null);

            CityRepository cityRep = new CityRepository();
            List<city> cityList = cityRep.Get().ToList();
            ViewBag.cities = new SelectList(cityList, "cityID", "name", null);
        }
Exemple #3
0
 public CityModel SaveCity(CityModel model)
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     City city = new City();
     AutoMapper.Mapper.Map(model, city);
     repo.Insert(city);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(city, model);
     return model;
 }
Exemple #4
0
 public CityModel GetCityById(int cityId)
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     CityModel cityModel = new CityModel();
     City city = new City();
     AutoMapper.Mapper.Map(cityModel, city);
     city = repo.GetAll().Where(x => x.CityId == cityId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(city, cityModel);
     return cityModel;
 }
Exemple #5
0
 public List<CityModel> GetAllCiites()
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     List<CityModel> cityModelList = new List<CityModel>();
     List<City> cityList = new List<City>();
     AutoMapper.Mapper.Map(cityModelList, cityList);
     cityList = repo.GetAll().OrderByDescending(x=>x.CityId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(cityList, cityModelList);
     return cityModelList;
 }
Exemple #6
0
 public bool CheckExistance(int cityId)
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     var city = repo.GetAll().Where(x => x.CityId == cityId).Count();
     //unitOfWork.Commit();
     if (city > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Exemple #7
0
 static CityService()
 {
     cityRepository = new CityRepository();
 }
Exemple #8
0
 public CityModel UpadteCity(CityModel model)
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     City city = new City();
     city = repo.GetAll().Where(x => x.CityId == model.CityId).FirstOrDefault();
     AutoMapper.Mapper.Map(model, city);
     repo.Update(city);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(city, model);
     return model;
 }
 public CityService(CityRepository cityRepo)
 {
     _cityRepo = cityRepo;
 }
Exemple #10
0
 /// <summary>
 /// Loads the City Repository.
 /// </summary>
 public static void Load()
 {
     CityRepository.Load();
 }
Exemple #11
0
 public CityServices()
 {
     _cityRepository = new CityRepository();
 }