public IActionResult Put(Guid id, [FromBody] IndicatorModel model) { try { model.Id = id; Indicator indicatorUpdated = indicatorLogic.Update(IndicatorModel.ToEntity(model)); return(CreatedAtRoute("GetIndicator", new { id = indicatorUpdated.Id }, IndicatorModel.ToModel(indicatorUpdated))); } catch (BusinessLogicInterfaceException e) { return(BadRequest(e.Message)); } }
public IActionResult Post([FromBody] IndicatorModel model) { try { Indicator indicator = model.ToEntity(); var indicatorCreated = indicatorLogic.Create(indicator); return(CreatedAtRoute("GetIndicator", new { id = indicatorCreated.Id }, IndicatorModel.ToModel(indicator))); } catch (BusinessLogicInterfaceException e) { return(BadRequest(e.Message)); } }
public IActionResult AddIndicator(Guid id, [FromBody] IndicatorModel model) { try { Indicator indicator = model.ToEntity(); Area area = areaLogic.Get(id); indicator.Area = area; var indicatorCreated = indicatorLogic.Create(indicator); areaLogic.AddIndicator(id, indicatorCreated.Id); return(NoContent()); } catch (BusinessLogicInterfaceException e) { return(BadRequest(e.Message)); } }
public IActionResult Post(int id, [FromBody] IndicatorModel model) { try { var indicator = IndicatorModel.ToEntity(model); indicator.Area = id; var toReturn = indicatorLogic.AddIndicator(indicator); List <UserIndicator> ui = new List <UserIndicator>(); return(Ok("Se agregó el area " + indicator.Name + " con el ID " + toReturn.ID + " al area ")); } catch (AlreadyExistsException) { return(BadRequest("No es posible agregar un area ya existente")); } catch (NullException) { return(BadRequest("No es posible agregar un area nula")); } catch (NullReferenceException) { return(BadRequest("No es posible agregar un area nula")); } catch (NotValidException) { return(BadRequest("No es posible agregar un area no válida")); } catch (DataBaseLogicException) { return(BadRequest("Error en la conexión con la base de datos")); } catch (InvalidOperationLogicException) { return(BadRequest("Error en el sistema")); } }