Esempio n. 1
0
        public void OnGet(string itemNumber, int catId = 0, int styleId = 0, int locationId = 0)
        {
            items                  = _dbReadService.GetWithIncludes <ProductInventory>();
            productList            = _dbReadService.GetWithIncludes <Product>();
            ViewData["Categories"] = _dbReadService.GetSelectList <Category>("CategoryId", "Name");
            ViewData["Styles"]     = _dbReadService.GetSelectList <Style>("StyleId", "Name");
            ViewData["Locations"]  = _dbReadService.GetSelectList <Location>("LocationId", "Name");

            if (styleId > 0)
            {
                items = items.Where(pv => pv.StyleId == styleId);
            }
            if (locationId > 0)
            {
                items = items.Where(pv => pv.LocationId == locationId);
            }
            if (catId > 0)
            {
                var products = _dbReadService.Get <Product>()
                               .Where(p => p.CategoryId == catId)
                               .Select(p => p.ProductId);
                if (products.Count() > 0)
                {
                    items = items.Where(pv => products.Contains(pv.ProductId));
                }
                else
                {
                    //never true, we do this because we cannot set items to null directly
                    items = items.Where(pv => pv.ProductId < 0);
                }
            }
            if (!string.IsNullOrEmpty(itemNumber))
            {
                var product = _dbReadService.Get <Product>()
                              .Where(p => p.ItemNumber.Equals(itemNumber))
                              .FirstOrDefault();
                if (product != null)
                {
                    items = items.Where(pv => pv.ProductId == product.ProductId);
                }
                else
                {
                    items = items.Where(pv => pv.ProductId < 0);
                }
            }
            //sort items by category, itemNumber, style and location
            items = items.OrderBy(pi => pi.Product.CategoryId).ThenBy(pi => pi.Product.ItemNumber)
                    .ThenBy(pi => pi.Style.Name).ThenBy(pi => pi.Location.Name);
        }
Esempio n. 2
0
 public void OnGet()
 {
     Items = _dbReadService.GetWithIncludes <AlbumInfo>();
     foreach (var item in Items)
     {
         item.Album.Band = _dbReadService.Get <Band>(item.Album.BandId);
     }
 }
        public IEnumerable <Course> GetCourses(string userId)
        {
            var courses = _db.GetWithIncludes <UserCourse>()
                          .Where(uc => uc.UserId.Equals(userId))
                          .Select(c => c.Course);

            return(courses);
        }
Esempio n. 4
0
        public IEnumerable <Course> GetCourses(string userId)
        {
            // Call the GetWithIncludes() for the UserCourses to fetch all the course id and user id combinations from the database.
            // select only the id combinations for the user id passed in to the GetCourses method by calling the Where LINQ method on the GetWithIncludes method.
            // select the Course objects included with the UserCourse entities by calling the Select()
            var courses = _db.GetWithIncludes <UserCourse>()
                          .Where(uc => uc.UserId.Equals(userId))
                          .Select(c => c.Course);

            return(courses);
        }
Esempio n. 5
0
        public void OnGet()
        {
            var videos     = _dbReadService.GetWithIncludes <Video>();
            var enumerable = videos as Video[] ?? videos.ToArray();

            foreach (var video in enumerable)
            {
                video.Album.Band = _dbReadService.Get <Band>(video.Album.BandId);
            }
            Items = enumerable;
        }
Esempio n. 6
0
 public void OnGet(string itemNumber, int catId = 0)
 {
     ViewData["Categories"] = _dbReadService.GetSelectList <Category>("CategoryId", "Name");
     items = _dbReadService.GetWithIncludes <Product>();
     if (catId > 0)
     {
         items = items.Where(p => p.CategoryId == catId);
     }
     if (!string.IsNullOrEmpty(itemNumber))
     {
         items = items.Where(p => p.ItemNumber.Equals(itemNumber));
     }
     items = items.OrderBy(p => p.CategoryId).ThenBy(p => p.ItemNumber);
 }
Esempio n. 7
0
 public void OnGet()
 {
     Items = _dbReadService.GetWithIncludes <Download>();
 }
Esempio n. 8
0
 public void OnGet()
 {
     Items = _dbReadService.GetWithIncludes <UserCourse>();
 }
Esempio n. 9
0
 public void OnGet()
 {
     Items = _dbReadService.GetWithIncludes <Album>();
 }
Esempio n. 10
0
 public void OnGet(int id)
 {
     Input          = _dbReadService.Get <Product>(id, true);
     PInventoryList = _dbReadService.GetWithIncludes <ProductInventory>()
                      .Where(pi => pi.ProductId == id);
 }
Esempio n. 11
0
 public void OnGet()
 {
     Items = _dbReadService.GetWithIncludes <Genre>();
 }
Esempio n. 12
0
        public void OnGet()

        {
            Items = _dbReadService.GetWithIncludes <Video>();
        }
Esempio n. 13
0
 public void OnGet()
 {
     items = _dbReadService.GetWithIncludes <Location>();
 }
Esempio n. 14
0
 public void OnGet()
 {
     items       = _dbReadService.GetWithIncludes <Category>();
     inventories = _dbReadService.Get <ProductInventory>();
 }
Esempio n. 15
0
 public void OnGet()
 {
     items = _dbReadService.GetWithIncludes <Style>();
 }
Esempio n. 16
0
 public void OnGet()
 {
     Items = _dbReadService.GetWithIncludes <BandMember>();
 }