public async Task AddNewItemAsync() { var result = await _toDoItems.AddAsync(this.NewItem); this.Items.Add(result); this.NewItem = new ToDoItem(); }
public IActionResult Post([FromBody] ToDoItem data) { try { var create = _todoItemService.AddAsync(data); return(Ok(create)); } catch (Exception e) { return(Ok(e.Message)); } }
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)); }
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)); }
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 }); }
public async Task <ActionResult <ToDoItem> > PostToDoItem(ToDoItem toDoItem) { await _toDoItems.AddAsync(toDoItem); return(CreatedAtAction("GetToDoItem", new { id = toDoItem.Id }, toDoItem)); }