public BusinnessLayerResult <City> UpdateById(City data) { string cityName = ToTitleCase(data.CityName); City city = efCityRepository.Find(x => x.CityName == cityName); BusinnessLayerResult <City> res = new BusinnessLayerResult <City> (); if (city != null && city.Id != data.Id) { if (city.CityName == cityName) { res.AddError(ErrorMessageCode.CityNameAlreadyExists, "Şehir Adı Kayıtlı"); } return(res); } res.Result = efCityRepository.Find(x => x.Id == data.Id); res.Result.CityName = ToTitleCase(data.CityName); res.Result.AreaCode = data.AreaCode; res.Result.IsActive = data.IsActive; res.Result.RegionId = data.RegionId; res.Result.PlateNo = data.PlateNo; if (Convert.ToInt32(Updates(res.Result)) == 0) { res.AddError(ErrorMessageCode.CityCouldNotFound, "Şehir Güncellenemedi."); } return(res); }
public BusinnessLayerResult <Country> GetCountryById(int id) { BusinnessLayerResult <Country> res = new BusinnessLayerResult <Country>(); res.Result = efCountryRepository.Find(x => x.Id == id); if (res == null) { res.AddError(ErrorMessageCode.CountryNotFound, "Ülke Bulunamadı."); } return(res); }
public BusinnessLayerResult <Country> UpdateCountry(Country data) { string countryName = ToTitleCase(data.CountryName); var kontrol = efCountryRepository.Find(x => x.Id == data.Id); Country country = Find(x => x.CountryName == countryName); BusinnessLayerResult <Country> res = new BusinnessLayerResult <Country>(); if (kontrol != null) { if (country != null && country.Id != data.Id) { if (country.CountryName == countryName) { res.AddError(ErrorMessageCode.CountryNameAlreadyExists, "Ülke Adı Kayıtlı."); } return(res); } res.Result = efCountryRepository.Find(x => x.Id == data.Id); res.Result.CountryName = ToTitleCase(data.CountryName); res.Result.NativeLanguage = data.NativeLanguage; res.Result.Flag = data.Flag; res.Result.CurrencyUnit = data.CurrencyUnit; //res.Result.IdentityCardTypeId = data.IdentityCardTypeId; if (string.IsNullOrEmpty(data.Flag) == false) { res.Result.Flag = data.Flag; } //if (Convert.ToInt32(efCountryRepository.Updates(res.Result)) == 0) if (Convert.ToInt32(Updates(res.Result)) == 0) { res.AddError(ErrorMessageCode.CountryCouldNotUpdated, "Ülke Güncellenemedi."); } } else { return(RegisterCountry(data)); } return(res); }
public BusinnessLayerResult <Region> RegisterRegion(Region region) { var kontrol = efRegionRepository.Find(x => x.Id == region.Id); string regionName = ToTitleCase(region.RegionName); //nick= CultureInfo.CurrentCulture.TextInfo.ToTitleCase(nick); Region rg = efRegionRepository.Find(x => x.RegionName == regionName || x.RegionCode == region.RegionCode); if (kontrol == null) { if (rg != null) { if (rg.RegionName == regionName) { blr.AddError(ErrorMessageCode.RegionNameAlreadyExists, "Bölge Adı Kullanılıyor."); } if (rg.RegionCode == region.RegionCode.ToUpper()) { blr.AddError(ErrorMessageCode.RegionCodeAlreadyExists, "Bölge Kodu Kullanılıyor."); } } else { int DbResult = Insert(new Region() { CountryId = region.CountryId, RegionName = ToTitleCase(region.RegionName), RegionCode = region.RegionCode.ToUpper(), IsActive = region.IsActive }); if (DbResult > 0) { blr.Result = Find(x => x.RegionName == regionName); } } } else { return(UpdateRegion(region)); } return(blr); }
public BusinnessLayerResult <Country> RegisterCountry(Country data) { string countryName = ToTitleCase(data.CountryName); var kontrol = efCountryRepository.Find(x => x.Id == data.Id); Country country = efCountryRepository.Find(x => x.CountryName == countryName); BusinnessLayerResult <Country> blr = new BusinnessLayerResult <Country>(); if (kontrol == null) { if (country != null) { if (country.CountryName == countryName) { blr.AddError(ErrorMessageCode.CountryNameAlreadyExists, "Ülke Adı Kullanılıyor."); } } else { int DbResult = Insert(new Country() { CountryName = countryName, Flag = data.Flag, CurrencyUnit = data.CurrencyUnit, IdentityCardTypeId = data.IdentityCardTypeId, NativeLanguage = data.NativeLanguage, }); if (DbResult > 0) { blr.Result = Find(x => x.CountryName == countryName); } } } else { return(UpdateCountry(data)); } return(blr); }
public BusinnessLayerResult <District> RegisterDistrict(District district) { var kontrol = efDistrictRepository.Find(x => x.Id == district.Id); string districtName = ToTitleCase(district.DistrictName); District dst = efDistrictRepository.Find(x => x.DistrictName == districtName || x.PostCode == district.PostCode); if (kontrol == null) { if (dst != null) { if (dst.DistrictName == districtName) { blr.AddError(ErrorMessageCode.DistrictNameAlreadyExists, "İlçe Adı Kullanılıyor."); } if (dst.PostCode == district.PostCode) { blr.AddError(ErrorMessageCode.PostCodeAlreadyExists, "Posta Kodu Kullanılıyor"); } } else { int DbResult = efDistrictRepository.Insert(new District() { DistrictName = ToTitleCase(district.DistrictName), CityId = district.CityId, IsActive = district.IsActive, PostCode = district.PostCode }); if (DbResult > 0) { blr.Result = efDistrictRepository.Find(x => x.DistrictName == districtName); } } } else { return(UpdateDistrict(district)); } return(blr); }
public BusinnessLayerResult <City> RegisterCity(City city) { string cityName = ToTitleCase(city.CityName); City cty = efCityRepository.Find(x => x.Id == city.Id); if (cty == null) { if (cty.CityName == cityName) { res.AddError(ErrorMessageCode.NameAlreadyExists, "Şehir Adı Kullanılıyor."); } if (cty.PlateNo == city.PlateNo) { res.AddError(ErrorMessageCode.PlateNoAlreadyExists, "Plaka Numarası Kullanılıyor."); } if (cty.AreaCode == city.AreaCode) { res.AddError(ErrorMessageCode.AreaCodeAlreadyExists, "Posta Numarası Kullanılıyor."); } else { int DbResult = Insert(new City() { CityName = ToTitleCase(city.CityName), AreaCode = city.AreaCode, IsActive = city.IsActive, PlateNo = city.PlateNo, RegionId = city.RegionId }); if (DbResult > 0) { res.Result = Find(x => x.CityName == cityName); } } } else { City kontrol = efCityRepository.Find(x => x.CityName == cityName || x.AreaCode == city.AreaCode || x.PlateNo == city.PlateNo); if (kontrol != null && kontrol.Id != city.Id) { if (kontrol.CityName == cityName) { res.AddError(ErrorMessageCode.NameAlreadyExists, "Şehir Adı Kullanılıyor"); } if (kontrol.AreaCode == city.AreaCode) { res.AddError(ErrorMessageCode.AreaCodeAlreadyExists, "Posta Kodu Kullanılıyor"); } if (kontrol.PlateNo == city.PlateNo) { res.AddError(ErrorMessageCode.PlateNoAlreadyExists, "Plaka Numarası Kullanılıyor"); } } res.Result = Find(x => x.Id == city.Id); res.Result.CityName = ToTitleCase(city.CityName); res.Result.AreaCode = city.AreaCode; res.Result.PlateNo = city.PlateNo; res.Result.RegionId = city.RegionId; if (Convert.ToInt32(Update(res.Result)) == 0) { res.AddError(ErrorMessageCode.CityCouldNotUpdated, "Şehir Güncellenemedi."); } } return(res); }