public void Update(UpdateRestrictedDto dto) { var restrictedIP = _restrictedIPsRepository.GetById(dto.Id); if (restrictedIP != null) { restrictedIP.IP = dto.IP; _restrictedIPsRepository.Update(restrictedIP); } else { try { throw new LogicalException(); } catch (LogicalException ex) { _logger.LogLogicalError (ex, "RestrictedIP entity with the id: '{0}', is not available." + " update operation failed.", dto.Id); throw; } } }
public IHttpActionResult Update([FromBody] UpdateRestrictedDto restrictedIP) { if (restrictedIP == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { _restrictedIPService.Update(restrictedIP); } catch (LogicalException ex) { return(BadRequest(ex.Message)); } catch { return(BadRequest(AppSettings .INTERNAL_SERVER_ERROR_MESSAGE)); } return(Ok()); }