private void Add() { var newToDo = new ToDoItem { Description = Description }; var result = toDoItemRepository.Add(newToDo); RaiseRequestClose(new DialogResult(ButtonResult.OK)); }
public IActionResult Post([FromBody] string title) { if (string.IsNullOrEmpty(title)) { return(BadRequest("The title cannot be null or empty")); } toDoItemRepository.Add(ToDoItem.Create(title)); return(Ok()); }
public IActionResult Create([FromBody] ToDoItem item) { if (item == null) { return(BadRequest()); } _toDoItemRepository.Add(item); return(CreatedAtRoute("GetToDo", new { id = item.ID }, item)); }
public IActionResult Add([FromBody] AddItemModel model) { var currentUserId = int.Parse(User.Identity.Name); var item = _mapper.Map <ToDoItem>(model); item.UserId = currentUserId; try { _ToDoItemService.Add(item); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
private async Task AddItemAsync(CancellationToken cancellationToken) { if (!string.IsNullOrWhiteSpace(_view.TodoInputText)) { var item = new TodoItem(null, _view.TodoInputText, false); _repository.Add(item); await _repository.SaveChangesAsync(cancellationToken); _view.AddToDoItem(item); _view.TodoInputText = string.Empty; } else { _messageBoxPresenter.Show(_view, "You must provide a title", "Validation error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }