public async Task <ActionResult> Post(Todo todo) { await _service.Create(todo); // Generates location header url value from the `GetById` method route return(CreatedAtAction("GetById", new { Id = 1 }, todo)); }
public ActionResult <Todo> Create([FromBody] Todo newTodos) { try { return(Ok(_service.Create(newTodos))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
public ActionResult <Todo> Create([FromBody] Todo newTodo) { try { return(Ok(_service.Create(newTodo))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <ActionResult <Todo> > CreateAsync([FromBody] Todo todo) { try { Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>(); todo.CreatorId = userInfo.Id; return(Ok(_tdService.Create(todo))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }