Example #1
0
        /**
         * Purpose: List the different products associated with each subproductType
         * Arguments:
         *      id - subtype id
         * Return:
         *      Redirects user to a list view of products
         */
        public async Task <IActionResult> Products([FromRoute] int id)
        {
            var model = new ProductSubTypeList(context);

            model.Products = await context.Product.OrderBy(s => s.Name).Where(p => p.ProductSubTypeId == id && p.IsActive == true).ToListAsync();

            model.ProductSubType = await context.ProductSubType.SingleAsync(p => p.ProductSubTypeId == id);

            model.ProductType = await context.ProductType.SingleAsync(p => p.ProductTypeId == model.ProductSubType.ProductTypeId);

            return(View(model));
        }
Example #2
0
        /**
         * Purpose: List the different subproducts for the user according to producttypes
         * Arguments:
         *      id - subtype id
         * Return:
         *      View(model) within the model there is a list that holds the different subproducts associated with each product type
         */
        public async Task <IActionResult> List([FromRoute] int id)
        {
            List <ProductSubType> ProductSubTypeList = await context.ProductSubType.OrderBy(s => s.Label).Where(p => p.ProductTypeId == id).ToListAsync();

            ProductSubTypeList.ForEach(CalculateTypeQuantities);

            var model = new ProductSubTypeList(context);

            model.ProductSubTypes = ProductSubTypeList;
            model.ProductType     = await context.ProductType.SingleAsync(t => t.ProductTypeId == id);

            return(View(model));
        }