public int CreateCity(BusinessEntities.CityMasterEntity cityMasterEntity) { using (var scope = new TransactionScope()) { var city = new CityMaster { CityName = cityMasterEntity.CityName, DistrictName = cityMasterEntity.DistrictName, StateName = cityMasterEntity.StateName.ToString() }; _unitOfWork.CityMasterRepository.Insert(city); _unitOfWork.Save(); scope.Complete(); return(city.PK_ID); } }
public BusinessEntities.CityMasterEntity GetCityById(int id) { BusinessEntities.CityMasterEntity objCityMaster = new BusinessEntities.CityMasterEntity(); if (id == 0) { return(objCityMaster); } var city = _unitOfWork.CityMasterRepository.GetByID(id); if (city != null) { Mapper.CreateMap <CityMaster, CityMasterEntity>(); var cityModel = Mapper.Map <CityMaster, CityMasterEntity>(city); return(cityModel); } return(null); }
public bool UpdateCity(int id, BusinessEntities.CityMasterEntity cityMasterEntity) { var success = false; if (cityMasterEntity != null) { using (var scope = new TransactionScope()) { var city = _unitOfWork.CityMasterRepository.GetByID(id); if (city != null) { city.CityName = cityMasterEntity.CityName; city.DistrictName = cityMasterEntity.DistrictName; city.StateName = cityMasterEntity.StateName.ToString(); _unitOfWork.CityMasterRepository.Update(city); _unitOfWork.Save(); scope.Complete(); success = true; } } } return(success); }