예제 #1
0
        public async Task <ActionResult <IEnumerable <Phone> > > GetAll([FromServices] IMediator mediator)
        {
            var request  = new GetAllPhonesRequest();
            var response = await mediator.Send(request);

            return(Ok(response));
        }
예제 #2
0
 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));
     }
 }