CustomerRepository.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // ======================================
  2. // Author: Ebenezer Monney
  3. // Email: info@ebenmonney.com
  4. // Copyright (c) 2017 www.ebenmonney.com
  5. //
  6. // ==> Gun4Hire: contact@ebenmonney.com
  7. // ======================================
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using Microsoft.EntityFrameworkCore;
  14. using DAL.Models;
  15. using DAL.Repositories.Interfaces;
  16. namespace DAL.Repositories
  17. {
  18. public class CustomerRepository : Repository<Customer>, ICustomerRepository
  19. {
  20. public CustomerRepository(ApplicationDbContext context) : base(context)
  21. { }
  22. public IEnumerable<Customer> GetTopActiveCustomers(int count)
  23. {
  24. throw new NotImplementedException();
  25. }
  26. public IEnumerable<Customer> GetAllCustomersData()
  27. {
  28. return appContext.Customers
  29. .Include(c => c.Orders).ThenInclude(o => o.OrderDetails).ThenInclude(d => d.Product)
  30. .Include(c => c.Orders).ThenInclude(o => o.Cashier)
  31. .OrderBy(c => c.Name)
  32. .ToList();
  33. }
  34. private ApplicationDbContext appContext
  35. {
  36. get { return (ApplicationDbContext)_context; }
  37. }
  38. }
  39. }