public string CreateNewCountry(CountryEntity ce) { var countryCodeAlreadyExists = CountryEntityCheck.DoesCountryCodeAlreadyExist(DataContext, ce.CountryCode); if (countryCodeAlreadyExists) { return(CountryEntityCheck.CountryCodeAlreadyExists); } var dwAlreadyExists = CountryEntityCheck.DoesCountryDwAlreadyExist(DataContext, ce.CountryDw, ce.Id); if (dwAlreadyExists) { return(CountryEntityCheck.DwCodeAlreadyExists); } var newCountryEntity = new COUNTRy { active = true, country1 = ce.CountryCode, country_dw = ce.CountryDw, country_description = ce.CountryName }; DataContext.COUNTRies.InsertOnSubmit(newCountryEntity); var returned = SubmitDbChanges(); return(returned); }
public string UpdateCountry(CountryEntity ce) { var dwAlreadyExists = CountryEntityCheck.DoesCountryDwAlreadyExist(DataContext, ce.CountryDw, ce.Id); if (dwAlreadyExists) { return(CountryEntityCheck.DwCodeAlreadyExists); } var countryDbEntry = DataContext.COUNTRies.Single(d => d.CountryId == ce.Id); countryDbEntry.country1 = ce.CountryCode; countryDbEntry.country_dw = ce.CountryDw; countryDbEntry.country_description = ce.CountryName; countryDbEntry.active = ce.Active; var returned = SubmitDbChanges(); return(returned); }