public IActionResult Post([FromBody] TodoItems todoItems)
        {
            if (todoItems == null || !todoItems.IsComplete || string.IsNullOrEmpty(todoItems.Name))
            {
                return(BadRequest("Objeto está vazio."));
            }

            _todoItemsService.Add(todoItems);
            return(CreatedAtRoute("Get", new { Id = todoItems.Id }, todoItems));
        }
Esempio n. 2
0
 public HttpResponseMessage CreateItem([FromBody] TodoItemViewModel item)
 {
     try
     {
         var newItem = EntityConvert <TodoItemViewModel, TodoItemModel>(item);
         _itemService.Add(newItem);
         return(Request.CreateResponse(HttpStatusCode.Created, newItem));
     }
     catch (Exception)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError));
     }
 }
Esempio n. 3
0
        public CreateTodoItemVm(ITodoItemsService todoItemsService)
        {
            this.todoItemsService = todoItemsService;

            CreateCommand = ReactiveCommand.CreateAsyncObservable(item =>
            {
                var todoItem         = new TodoItem();
                todoItem.Name        = Name;
                todoItem.Description = Description;
                todoItem.Duration    = Duration;

                return(todoItemsService.Add(todoItem));
            });

            CreateCommand.Subscribe(_ =>
            {
                Name     = Description = null;
                Duration = 1;
            });
        }