Ejemplo n.º 1
0
        public async Task AddNewItemAsync()
        {
            var result = await _toDoItems.AddAsync(this.NewItem);

            this.Items.Add(result);

            this.NewItem = new ToDoItem();
        }
Ejemplo n.º 2
0
 public IActionResult Post([FromBody] ToDoItem data)
 {
     try
     {
         var create = _todoItemService.AddAsync(data);
         return(Ok(create));
     }
     catch (Exception e)
     {
         return(Ok(e.Message));
     }
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> AddAsync(IndexMeneger index)
        {
            await _toDo.AddAsync(new Itam
            {
                Title = index.Title
            });

            _indmen = new IndexMeneger()
            {
                Itams = _toDo.GetItams()
            };
            return(View("Index", _indmen));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Add(ToDoDto model)
        {
            if (ModelState.IsValid)
            {
                model.UserId = User.FindFirstValue(ClaimTypes.NameIdentifier);;

                var result = await _toDoService.AddAsync(model);

                if (result.HasError)
                {
                    return(RedirectToError());
                }

                return(RedirectToAction("Index", "ToDo"));
            }

            return(View(model));
        }
Ejemplo n.º 5
0
        private async void AddToDo(object parameter)
        {
            ToDoDto toDo = new ToDoDto {
                Text = "New to do..", IsCompleted = false
            };

            var result = await _toDoService.AddAsync(toDo);

            if (result.HasError)
            {
                System.Windows.Forms.MessageBox.Show("An error occured while inserting new to do to the database.");
                return;
            }

            ToDoes.Add(
                new ToDoBindingModel
            {
                Id          = result.Data.Id,
                Text        = result.Data.Text,
                IsCompleted = result.Data.IsCompleted,
                IsDeleted   = result.Data.IsDeleted
            });
        }
Ejemplo n.º 6
0
        public async Task <ActionResult <ToDoItem> > PostToDoItem(ToDoItem toDoItem)
        {
            await _toDoItems.AddAsync(toDoItem);

            return(CreatedAtAction("GetToDoItem", new { id = toDoItem.Id }, toDoItem));
        }