Exemplo n.º 1
0
 // POST api/lists
 public IHttpActionResult Post([FromBody] TodoListDto value)
 {
     if (!ValidatePost(value))
     {
         return(BadRequest("Ensure list has name field..."));
     }
     return(Ok(ToDto(_todoRepository.AddList(value.name))));
 }
Exemplo n.º 2
0
        private async Task ExecuteAddNewtItem()
        {
            var result = await _dialogs.PromptAsync(
                message : "Name of ToDo Item",
                title : "Add New Item");

            var newItemTitle = result.Value;

            bool makeActive = true;

            if (this.TodoLists.Any(x => x.IsActive))
            {
                makeActive = await _dialogs.ConfirmAsync(
                    $"Do you want to make list '{result.Value}' your active list?",
                    "Active List",
                    okText : "Yes",
                    cancelText : "No");
            }

            _dialogs.ShowLoading(string.Empty);

            var created = await _repo.AddList(new Models.TodoList
            {
                Title = newItemTitle
            });

            // if user wants to make it active, activate this one,
            // calling the repo method will deactivate all other lists
            if (makeActive)
            {
                await _repo.ActivateList(created.Id);
            }

            TodoLists.Add(created);

            _dialogs.HideLoading();

            // navigate to the new list
            SelectItem.Execute(created);
        }