Example #1
0
        public static void SortCustomers(List <SelectListItem> customers)
        {
            MbmStoreContext db = new MbmStoreContext();

            foreach (Invoice invoice in db.Invoices.Include(c => c.Customer).ToList())
            {
                customers.Add(new SelectListItem {
                    Text = invoice.Customer.FirstName + " " + invoice.Customer.LastName, Value = invoice.Customer.CustomerId.ToString()
                });
            }

            // removes duplicate entries with same ID from a IEnumerable
            customers = customers
                        .GroupBy(x => x.Value)
                        .Select(y => y.First())
                        .OrderBy(z => z.Text)
                        .ToList <SelectListItem>();
        }
Example #2
0
        // object
        // private Repository repository = new Repository();

        // GET: Catalogue
        public ActionResult Index(string category, int page = 1)
        {
            // Repository repository = new Repository();

            // object that we use to connect to the db
            db = new MbmStoreContext();

            ProductsListViewModel model = new ProductsListViewModel()
            {
                Products = db.Products
                           .Where(p => category == null || p.Category == category)
                           .OrderBy(p => p.ProductId)
                           .Skip((page - 1) * PageSize)
                           .Take(PageSize)
                           .ToList(),

                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = category == null?
                                   db.Products.Count() :
                                       db.Products.Where(e => e.Category == category).Count()
                },
                CurrentCategory = category,

                MusicCDs = db.MusicCDs.Include(m => m.Tracks).ToList()
            };

            List <SelectListItem> Quantity = new List <SelectListItem>();

            for (int i = 1; i <= 100; i++)
            {
                Quantity.Add(new SelectListItem {
                    Text = i.ToString(), Value = i.ToString()
                });
            }

            ViewBag.Quantity = Quantity;

            return(View(model));
        }
        // GET: Catalogue
        public ActionResult Index(string category, int page = 1)
        {
            db = new MbmStoreContext();
            ProductsListViewModel model = new ProductsListViewModel
            {
                Products = db.Products
                           .Where(p => category == null || p.Category == category)
                           .OrderBy(p => p.ProductId)
                           .Skip((page - 1) * PageSize)
                           .Take(PageSize).ToList(),

                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = category == null?db.Products.Count() : db.Products.Where(e => e.Category == category).Count()
                },
                CurrentCategory = category
            };

            return(View(model));
        }
Example #4
0
 public NavController()
 {
     db = new MbmStoreContext();
 }
 public NavigationMenuViewComponent(MbmStoreContext dbContext)
 {
     dataContext = dbContext;
 }
 public CatalogueController(MbmStoreContext dbContext)
 {
     dataContext = dbContext;
 }
 public MovieController(MbmStoreContext context)
 {
     _context = context;
 }
 public InvoiceController()
 {
     db = new MbmStoreContext();
 }
 public MusicController(MbmStoreContext context)
 {
     _context = context;
 }
Example #10
0
 public InvoiceController(MbmStoreContext dbContext)
 {
     dataContext = dbContext;
 }
 public OrderController(Cart cartService, MbmStoreContext dbContext)
 {
     cart        = cartService;
     dataContext = dbContext;
 }
 public CustomersController(MbmStoreContext context)
 {
     _context = context;
 }
Example #13
0
 // constructor
 // instantiate a new repository object
 public CartController()
 {
     db = new MbmStoreContext();
 }
 public CatalogueController()
 {
     db = new MbmStoreContext();
 }
Example #15
0
 public CartController(MbmStoreContext dbContext, Cart cartService)
 {
     cart        = cartService;
     dataContext = dbContext;
 }
Example #16
0
 public BookController(MbmStoreContext context)
 {
     _context = context;
 }
 public CustomerController(MbmStoreContext dbContext)
 {
     dataContext = dbContext;
 }