public IActionResult CreateStage([FromBody] StageForCreationDto stage) { try { if (stage == null) { _logger.LogError("Stage object sent from client is null."); return(BadRequest("Stage object is null")); } if (!ModelState.IsValid) { _logger.LogError("Invalid Stage object sent from client."); return(BadRequest("Invalid model object")); } bool succes = _stageLogic.Create(stage); return(Ok("Stage is created")); } catch (Exception ex) { return(StatusCode(500, "Internal server error")); } }
public bool Create(StageForCreationDto stageForCreation) { try { Stage DataEntity = _mapper.Map <Stage>(stageForCreation); _repository.Create(DataEntity); _repository.Save(); return(true); } catch (Exception ex) { _logger.LogError($"Something went wrong inside CreateStage action: {ex.Message}"); throw new Exception(); } }