public async Task <IActionResult> PutAsync(Guid id, [FromBody] RegulationInputModel model) { if (default(Guid).Equals(id)) { AddNotification("O Id do regulamento não foi informado."); return(ResponseInvalid()); } if (ModelState.IsValid) { var regulation = new Regulation(model.Description); await _regulationService.UpdateAsync(id, regulation); if (ValidOperation()) { return(NoContent()); } return(ResponseInvalid()); } NotifyModelStateError(); return(ResponseInvalid()); }
public async Task <IActionResult> PostAsync([FromBody] RegulationInputModel model) { if (ModelState.IsValid) { var regulation = new Regulation(model.Description); await _regulationService.AddAsync(regulation); if (ValidOperation()) { return(Created(GetRouteById(regulation.Id), new { id = regulation.Id })); } return(ResponseInvalid()); } NotifyModelStateError(); return(ResponseInvalid()); }