From 7e778d61545f7f164c7f1ff21764ea67e6f08e05 Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Thu, 23 Jun 2022 13:26:21 -0500 Subject: [PATCH] implemented getting all quotes --- server/Controllers/v1/QuotesController.cs | 6 ++--- .../Repositories/QuoteRepository.cs | 23 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/server/Controllers/v1/QuotesController.cs b/server/Controllers/v1/QuotesController.cs index fe35739..2eca4b6 100644 --- a/server/Controllers/v1/QuotesController.cs +++ b/server/Controllers/v1/QuotesController.cs @@ -44,10 +44,10 @@ namespace server.Controllers.v1 } } - // TODO + // TODO: Implement getquotesbyid [MapToApiVersion("1.0")] - [HttpGet] - public async Task> GetQuoteByIdAsync(int id) + [HttpGet("{id:int}")] + public Task> GetQuoteByIdAsync(int id) { throw new NotImplementedException(); } diff --git a/server/Persistence/Repositories/QuoteRepository.cs b/server/Persistence/Repositories/QuoteRepository.cs index 44454b8..de56a2c 100644 --- a/server/Persistence/Repositories/QuoteRepository.cs +++ b/server/Persistence/Repositories/QuoteRepository.cs @@ -1,9 +1,5 @@ -using server.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using MongoDB.Driver; +using server.Models; namespace server.Persistence.Repositories { @@ -16,10 +12,19 @@ namespace server.Persistence.Repositories _context = context; } - // TODO: Implement GetQuotesAsync() method. - public Task> GetQuotesAsync(QuoteFilter filter) + // TODO: Implement optional, but possible filters for query. + public async Task> GetQuotesAsync(QuoteFilter filter) { - throw new NotImplementedException(); + try + { + var query = _context.Quotes.AsQueryable(); + return await query.ToListAsync(); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } } // TODO: Implement GetQuoteByIdAsync() method.