예제 #1
0
        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,
            }));
        }
예제 #2
0
        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));
        }
예제 #3
0
 public StreetDto Add(StreetDto subject)
 {
     return(streetService.Add(subject));
 }