예제 #1
0
        // GET: api/TodoItems/5
        public async Task <IHttpActionResult> GetTodoItem(int id)
        {
            BllTodoItem todoItem = await service.Get(id);

            if (todoItem == null)
            {
                return(NotFound());
            }

            return(Ok(todoItem.ToViewModel()));
        }
예제 #2
0
        public async Task <IHttpActionResult> Post(TodoItemModel item)
        {
            item.Created = DateTime.Now;

            BllTodoItem result = await service.Add(item.ToBll());

            if (result == null)
            {
                return(BadRequest(ModelState));
            }

            return(CreatedAtRoute("DefaultApi", new { id = item.Id }, result.ToViewModel()));
        }