Пример #1
0
        public static async Task <ProductItemModel> Convert(this ProductItem productItem, ApplicationDbContext db, bool addListData = true)
        {
            var model = new ProductItemModel
            {
                ItemId       = productItem.ItemId,
                ProductId    = productItem.ProductId,
                Items        = addListData ? await db.Items.ToListAsync() : null,
                Products     = addListData ? await db.Products.ToListAsync() : null,
                ItemTitle    = (await db.Items.FirstOrDefaultAsync(i => i.Id.Equals(productItem.ItemId))).Title,
                ProductTitle = (await db.Products.FirstOrDefaultAsync(p => p.Id.Equals(productItem.ProductId))).Title
            };

            return(model);
        }
Пример #2
0
        public static async Task <ProductItemModel> Convert
            (this Product_Item productItem, ApplicationDbContext db, bool addListData = true)
        //Only fill collections if the parameter passed in is true
        {
            var model = new ProductItemModel
            {
                ItemID    = productItem.ItemID,
                ProductID = productItem.ProductID,
                Items     = addListData ? await db.Items.ToListAsync() : null,
                Products  = addListData ? await db.Products.ToListAsync() : null,

                ItemTitle    = (await db.Items.FirstOrDefaultAsync(i => i.ID.Equals(productItem.ItemID))).Title,
                ProductTitle = (await db.Products.FirstOrDefaultAsync(p => p.ID.Equals(productItem.ProductID))).Title
            };

            return(model);
        }