You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RequestRepository.cs 981B

123456789101112131415161718192021222324252627282930
  1. using Diligent.WebAPI.Business.Interfaces;
  2. using Diligent.WebAPI.Data;
  3. using Diligent.WebAPI.Data.Entities;
  4. using MongoDB.Driver;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Diagnostics.CodeAnalysis;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace Diligent.WebAPI.Business.Services
  12. {
  13. [ExcludeFromCodeCoverage]
  14. public class RequestRepository : BaseRepository<Request>, IRequestRepository
  15. {
  16. protected new IMongoCollection<Request> _dbCollection;
  17. public RequestRepository(IMongoDBContext context) : base(context)
  18. {
  19. _dbCollection = _mongoContext.GetCollection<Request>(typeof(Request).Name);
  20. }
  21. public async Task<Request> FindRequestAsync(string customerId, string roomId)
  22. {
  23. var requests = await _dbCollection.FindAsync(x => x.SenderId == customerId && x.RoomId == roomId);
  24. return await requests.FirstOrDefaultAsync();
  25. }
  26. }
  27. }