public IActionResult Create(ToDoViewModel toDoViewModel) { var data = _todoListService.Create(toDoViewModel); if (data > 0) { return(Ok(data)); } return(BadRequest("Bad Request")); }
/// <summary> /// creates todo-list item /// </summary> /// <param name="todoListModel">todo-list model to create</param> /// <returns>created todo-list model</returns> public IHttpActionResult Post(TodoListModel todoListModel) { try { return(Ok(_todoListsService.Create(todoListModel))); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IActionResult Create(int userId, TodoListCreateVm todoListCreateVm) { var user = _userService.Get(userId); if (user == null) { return(NotFound()); } var todoList = _mapper.Map <TodoList>(todoListCreateVm); todoList.User = user; _todoListService.Create(todoList); return(CreatedAtRoute( "GetTodoList", new { userId = user.Id, todoListId = todoList.Id }, todoList.Id)); }
public string Post([FromBody] string value) { // to save item. return(_todoListService.Create(value)); }