Exemplo n.º 1
0
        //POST /api/TodoItem
        /// <summary>
        /// Creates a new Todo Item for this user (using POST because we're generating an ID)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <IHttpActionResult> Post(TodoItemModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var todoItem = new TodoItem
            {
                User        = await UserManager.FindByNameAsync(User.Identity.Name),
                Description = model.Description,
                Done        = false
            };

            await TodoItemRepository.CreateAsync(todoItem);

            return(CreatedAtRoute("DefaultApi", new { todoItem.Id }, Models.Output.TodoItem.Project(todoItem)));
        }