private StreetEntity AddOrCreate(AddressImport import, int districtId) { var result = _streetService.GetItem(x => x.StreetName == import.Name); if (result != null) { return(result); } return(_streetService.Add(new StreetEntity { StreetName = import.Name, DistrictId = districtId, })); }
public IActionResult SaveEntity(StreetViewModel streetVm) { if (!ModelState.IsValid) { IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); return(new BadRequestObjectResult(allErrors)); } if (streetVm.Id == 0) { _streetService.Add(streetVm); } else { _streetService.Update(streetVm); } _streetService.Save(); return(new OkObjectResult(streetVm)); }
public StreetDto Add(StreetDto subject) { return(streetService.Add(subject)); }