Created
December 7, 2019 05:13
-
-
Save pkellner/b05f7817adfc3fed9338e89ad0262c90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using EFLibSvcc.Models; | |
using Microsoft.EntityFrameworkCore; | |
namespace CarvedRock.Api.Repositories | |
{ | |
public class RoomRepository | |
{ | |
private readonly svcodecampContext _dbContext; | |
public RoomRepository(svcodecampContext dbContext) | |
{ | |
_dbContext = dbContext; | |
} | |
public async Task<IEnumerable<LectureRooms>> GetAll() | |
{ | |
return await _dbContext.LectureRooms.ToListAsync(); | |
} | |
public async Task<IEnumerable<LectureRooms>> GetByCodeCampYear(string year) | |
{ | |
var LectureRoomsIds = await (from session in _dbContext.Sessions | |
join ccy in _dbContext.CodeCampYear on session.CodeCampYearId equals ccy.Id | |
where ccy.UrlPostToken == year | |
select session.LectureRoomsId).Distinct().ToListAsync(); | |
return await (from room in _dbContext.LectureRooms | |
orderby room.Number.ToLower() | |
where LectureRoomsIds.Contains(room.Id) | |
select room) | |
.ToListAsync(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment