public async Task <IActionResult> PutCity(int id, City city) { if (id != city.Id) { return(BadRequest()); } _context.Entry(city).State = EntityState.Modified; var cityValidator = new CityValidator(); var resoultValidator = cityValidator.Validate(city); if (!resoultValidator.IsValid) { return(BadRequest(resoultValidator.Errors)); } var result = await _citiesService.PutCity(id, city); if (result) { return(Ok()); } return(NoContent()); }
private static void ValidateCity(string city) { var validator = new CityValidator(); var result = validator.Validate(city); if (!result.IsValid) { throw new IdentityDomainException(nameof(city)); } }
public async Task <IActionResult> PutCity(int id, City city) { if (id != city.Id) { return(BadRequest()); } var cityValidator = new CityValidator(); var resultValidation = cityValidator.Validate(city); if (!resultValidation.IsValid) { } var result = await _CitiesService.PutCity(id, city); if (result) { return(Ok()); } return(NoContent()); }
public async Task <IActionResult> PutCity(int id, City city) { if (id != city.Id) { return(BadRequest()); } var validator = new CityValidator(); var resultValid = validator.Validate(city); if (!resultValid.IsValid) { return(BadRequest(resultValid.Errors)); } var result = await _cityServices.Update(city); if (result) { return(Ok()); } return(NoContent()); }
public ResponseBase <TBL_SLI_CITY> Insert(TBL_SLI_CITY country) { CityValidator validator; try { validator = new CityValidator(); _results = validator.Validate(country); if (_results.IsValid) { country.BIT_STATE = true; country.VCH_NAME = country.VCH_NAME.ToUpper(); var cityFound = _context.TBL_SLI_CITY.Where(x => x.VCH_NAME.Contains(country.VCH_NAME)).FirstOrDefault(); _response = new UtilityResponse <TBL_SLI_CITY>().SetResponseBaseForUniqueValidation(); if (cityFound == null) { _context.TBL_SLI_CITY.Add(country); _context.SaveChanges(); _response = new UtilityResponse <TBL_SLI_CITY>().SetResponseBaseForObj(country); } } else { _response = new UtilityResponse <TBL_SLI_CITY>().SetResponseBaseFunctionalErrors(_results); } return(_response); } catch (Exception ex) { _response = new UtilityResponse <TBL_SLI_CITY>().SetResponseBaseForException(ex); return(_response); } finally { _response = null; _results = null; validator = null; _context.Database.Connection.Close(); } }
public async Task <IActionResult> PutCity(int id, City city) { if (id != city.Id) { return(BadRequest()); } var CityValidatort = new CityValidator(); var valiresult = CityValidatort.Validate(city); if (!valiresult.IsValid) { return(BadRequest(valiresult.Errors)); } var _cityService = new CityService(_context); var result = await _cityService.PutCity(id, city); if (result) { return(Ok()); } return(NoContent()); }