public async Task <(IEnumerable <OrderForList>, int)> GetOrders(IFopRequest request) { var(orders, totalCount) = _db.Orders .Include(p => p.User) .Select(p => new OrderForList { OrderId = p.OrderId, DateOrder = p.DateOrder, ShipAddress = p.ShipAddress, UserName = p.User.UserName, PhoneNumber = p.User.PhoneNumber }).ApplyFop(request); return(await orders.ToListAsync(), totalCount); }
public async Task <(IEnumerable <ProductForList>, int)> GetListProduct(IFopRequest request) { var totalCountProduct = _db.Products.Count(); var(listProducts, totalCount) = _db.Products.Include(p => p.Category).Select(p => new ProductForList { Id = p.Id, ProductName = p.ProductName, CategoryId = p.CategoryId, CategoryName = p.Category.CategoryName, Price = (int)p.Price, PhotoUrl = p.Photos.First().Url, Weight = p.Weight, Company = p.Company, TotalCount = totalCountProduct }).ApplyFop(request); return(await listProducts.ToListAsync(), totalCount); }
public static (IQueryable <T>, int) ApplyFop <T>(this IQueryable <T> source, IFopRequest request) {
public async Task <(List <Student>, int)> RetrieveStudents(IFopRequest request) { var(filteredStudents, totalCount) = _context.Students.Include(x => x.Department).ApplyFop(request); return(await filteredStudents.ToListAsync(), totalCount); }
public async Task <(IEnumerable <BlogForList>, int)> GetBlogs(int blogCategoryId, IFopRequest request) { var(blogs, totalCount) = _db.Blogs .Include(p => p.CategoryBlog) .Include(p => p.PhotoBlog) .Where(p => p.CategoryBlogId == blogCategoryId) .Select(p => new BlogForList { BlogId = p.BlogId, Title = p.Title, ShortDescription = p.ShortDescription, BlogCategoryId = p.CategoryBlogId, BlogCategoryName = p.CategoryBlog.CategoryBlogName, PhotoUrl = p.PhotoBlog.Url }).ApplyFop(request); return(await blogs.ToListAsync(), totalCount); }