public string CreateNewCarSegment(CarSegmentEntity cse) { var segmentAlreadyExistsInCountry = CarSegmentEntityCheck.DoesSegmentExistForCountry(DataContext, cse.CarSegmentName, cse.CountryId); if (segmentAlreadyExistsInCountry) { return(CarSegmentEntityCheck.SegmentAlreadyExistsForCountry); } var countryCode = DataContext.COUNTRies.Single(d => d.CountryId == cse.CountryId).country1; var newCarSegmentEnitiy = new CAR_SEGMENT { IsActive = true, car_segment1 = cse.CarSegmentName, country = countryCode, }; DataContext.CAR_SEGMENTs.InsertOnSubmit(newCarSegmentEnitiy); var returned = SubmitDbChanges(); return(returned); }
public string UpdateCarSegment(CarSegmentEntity cse) { var carSegmentDbEntry = DataContext.CAR_SEGMENTs.Single(d => d.car_segment_id == cse.Id); var segmentAlreadyExistsInCountry = CarSegmentEntityCheck.DoesSegmentExistForCountry(DataContext, cse.CarSegmentName, carSegmentDbEntry.COUNTRy1.CountryId, cse.Id); if (segmentAlreadyExistsInCountry) { return(CarSegmentEntityCheck.SegmentAlreadyExistsForCountry); } carSegmentDbEntry.car_segment1 = cse.CarSegmentName; carSegmentDbEntry.IsActive = cse.Active; var returned = SubmitDbChanges(); return(returned); }