public async Task <ActionResult <ToDoTaskResponse> > CreateToDoTask(ToDoTaskRequest toDoTask) { if (!ModelState.IsValid) { return(BadRequest()); } try { var result = await _toDoTaskService.AddToDoTask(HttpContext.User, toDoTask); return(result); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorRetrieveDatabase)); } }
public IActionResult Post([FromBody] ToDoTask toDoTask) { try { if (ModelState.IsValid) { var addedToDoTask = _toDoTaskService.AddToDoTask(toDoTask).Result; return(Ok(addedToDoTask)); } else { return(BadRequest()); } } catch (Exception ex) { //TODO log Exception return(BadRequest(ex.Message)); } }