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); }
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); }
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); }
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; }
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); }
public void OnGet() { Items = _dbReadService.GetWithIncludes <Download>(); }
public void OnGet() { Items = _dbReadService.GetWithIncludes <UserCourse>(); }
public void OnGet() { Items = _dbReadService.GetWithIncludes <Album>(); }
public void OnGet(int id) { Input = _dbReadService.Get <Product>(id, true); PInventoryList = _dbReadService.GetWithIncludes <ProductInventory>() .Where(pi => pi.ProductId == id); }
public void OnGet() { Items = _dbReadService.GetWithIncludes <Genre>(); }
public void OnGet() { Items = _dbReadService.GetWithIncludes <Video>(); }
public void OnGet() { items = _dbReadService.GetWithIncludes <Location>(); }
public void OnGet() { items = _dbReadService.GetWithIncludes <Category>(); inventories = _dbReadService.Get <ProductInventory>(); }
public void OnGet() { items = _dbReadService.GetWithIncludes <Style>(); }
public void OnGet() { Items = _dbReadService.GetWithIncludes <BandMember>(); }