implemented getting all quotes

This commit is contained in:
StevanFreeborn
2022-06-23 13:26:21 -05:00
parent 2cbab773d0
commit 7e778d6154
2 changed files with 17 additions and 12 deletions
+3 -3
View File
@@ -44,10 +44,10 @@ namespace server.Controllers.v1
} }
} }
// TODO // TODO: Implement getquotesbyid
[MapToApiVersion("1.0")] [MapToApiVersion("1.0")]
[HttpGet] [HttpGet("{id:int}")]
public async Task<ActionResult<Quote>> GetQuoteByIdAsync(int id) public Task<ActionResult<Quote>> GetQuoteByIdAsync(int id)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -1,9 +1,5 @@
using server.Models; using MongoDB.Driver;
using System; using server.Models;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace server.Persistence.Repositories namespace server.Persistence.Repositories
{ {
@@ -16,10 +12,19 @@ namespace server.Persistence.Repositories
_context = context; _context = context;
} }
// TODO: Implement GetQuotesAsync() method. // TODO: Implement optional, but possible filters for query.
public Task<List<Quote>> GetQuotesAsync(QuoteFilter filter) public async Task<List<Quote>> 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. // TODO: Implement GetQuoteByIdAsync() method.