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 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; }