public void DeleteCity(int cityId) { //unitOfWork.StartTransaction(); CityRepository repo = new CityRepository(unitOfWork); repo.Delete(x => x.CityId == cityId); //unitOfWork.Commit(); }
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); }
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; }
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; }
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; }
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; } }
static CityService() { cityRepository = new CityRepository(); }
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; }
/// <summary> /// Loads the City Repository. /// </summary> public static void Load() { CityRepository.Load(); }
public CityServices() { _cityRepository = new CityRepository(); }