Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://www.youtube.com/watch?v=rtXpYpZdOzM&t=1159s
- using Queries.Core.Domain;
- using Queries.Core.Repositories;
- using System.Collections.Generic;
- using System.Data.Entity;
- using System.Linq;
- namespace Queries.Persistence.Repositories
- {
- public class CourseRepository : Repository<Course>, ICourseRepository
- {
- public CourseRepository(PlutoContext context)
- : base(context)
- {
- }
- public IEnumerable<Course> GetTopSellingCourses(int count)
- {
- return PlutoContext.Courses.OrderByDescending(c => c.FullPrice).Take(count).ToList();
- }
- public IEnumerable<Course> GetCoursesWithAuthors(int pageIndex, int pageSize = 10)
- {
- return PlutoContext.Courses
- .Include(c => c.Author)
- .OrderBy(c => c.Name)
- .Skip((pageIndex - 1) * pageSize)
- .Take(pageSize)
- .ToList();
- }
- public PlutoContext PlutoContext
- {
- get { return Context as PlutoContext; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement