public async Task <ActionResult> DeleteLabel([FromRoute] int id) { var request = new DeleteLabelCommand(User.Identity?.Name, id); var response = await _mediator.Send(request); return(response.Match <ActionResult>( ok => NoContent(), notFound => NotFound() )); }
public async Task <OneOf <Ok, NotFound> > Handle(DeleteLabelCommand request, CancellationToken cancellationToken) { var label = await _labelsRepository .GetAsync(label => label.Id == request.Id && label.UserLogin == request.UserLogin); if (label == null) { return(new NotFound()); } _labelsRepository.Delete(label); await _labelsRepository.SaveChangesAsync(); return(new Ok()); }
public void RaiseCanExecuteChanged() { EditLabelCommand.RaiseCanExecuteChanged(); DeleteLabelCommand.RaiseCanExecuteChanged(); }