public async Task <ActionResult <IEnumerable <Phone> > > GetAll([FromServices] IMediator mediator) { var request = new GetAllPhonesRequest(); var response = await mediator.Send(request); return(Ok(response)); }
public Task <IEnumerable <Phone> > Handle(GetAllPhonesRequest request, CancellationToken cancellationToken) { using (var db = _factory.Create()) { var phonesCollection = db.GetCollection <Phone>(); var result = phonesCollection.FindAll(); return(Task.FromResult(result)); } }