public static Area BuildArea(PostcodeDistrict postcodeDistrict) { return new Area { PostcodePrefix = postcodeDistrict.PostcodeDistrictPrefix, FriendlyName = postcodeDistrict.PostcodeDistrictFriendlyName }; }
public bool UpdatePostcodeDistrict(string postcodeAreaReference, string postcodeDistrictReference, PostcodeDistrict postcodeDistrict) { Check.If(postcodeAreaReference).IsNotNullOrEmpty(); Check.If(postcodeDistrictReference).IsNotNullOrEmpty(); Check.If(postcodeDistrict).IsNotNull(); return _postcodeDistrictRepository.UpdatePostcodeDistrict(postcodeAreaReference, postcodeDistrictReference, postcodeDistrict); }
public string CreatePostcodeDistrict(string postcodeAreaReference, PostcodeDistrict postcodeDistrict) { Check.If(postcodeAreaReference).IsNotNullOrEmpty(); Check.If(postcodeDistrict).IsNotNull(); var result = _postcodeDistrictRepository.CreatePostcodeDistrict(postcodeAreaReference, postcodeDistrict.CreateReference(_referenceGenerator)); return result ? postcodeDistrict.PostcodeDistrictReference : null; }
public bool CreatePostcodeDistrict(string postcodeAreaReference, PostcodeDistrict postcodeDistrict) { if (postcodeAreaReference.IsNullOrEmpty()) return false; var postcodeArea = _propertiesContext.PostcodeAreas.Active() .Include(p => p.PostcodeDistricts) .FirstOrDefault(p => p.PostcodeAreaReference == postcodeAreaReference); if (postcodeArea.IsNull()) return false; postcodeArea.PostcodeDistricts.Add(postcodeDistrict); return _propertiesContext.SaveChanges() > 0; }
public bool UpdatePostcodeDistrict(string postcodeAreaReference, string postcodeDistrictReference, PostcodeDistrict postcodeDistrict) { if(postcodeAreaReference.IsNullOrEmpty() || postcodeDistrictReference.IsNullOrEmpty()) return false; var postcodeArea = _propertiesContext.PostcodeAreas.Active() .Include(p => p.PostcodeDistricts) .FirstOrDefault(p => p.PostcodeAreaReference == postcodeAreaReference); var existingPostcodeDistrict = postcodeArea?.PostcodeDistricts.Active() .FirstOrDefault(x => x.PostcodeDistrictReference == postcodeDistrictReference); if (existingPostcodeDistrict.IsNull()) return false; var isDirty = _postcodeDistrictMapper.Map(postcodeDistrict, existingPostcodeDistrict); return !isDirty || _propertiesContext.SaveChanges() > 0; }