示例#1
0
        // GET: Variations/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var variation = await _context.Variation.SingleOrDefaultAsync(m => m.Id == id);

            if (variation == null)
            {
                return(NotFound());
            }
            List <PatternPiece> AllPatPieces = new List <PatternPiece>();

            foreach (var item in _context.PatternPiece)
            {
                AllPatPieces.Add(item);
            }
            List <PatPieceVariation> PPVwithThisVariation = new List <PatPieceVariation>();

            foreach (var item in _context.PatPieceVariation.Where(x => x.VariationId == variation.Id).ToList())
            {
                PPVwithThisVariation.Add(item);
            }
            var model = new PatPieceViewModel
            {
                Variation          = variation,
                PatPieces          = AllPatPieces,
                PatPieceVariations = PPVwithThisVariation,
            };

            return(View(model));
        }
        // GET: Styles/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var style = await _context.Style.SingleOrDefaultAsync(m => m.Id == id);

            if (style == null)
            {
                return(NotFound());
            }

            List <PatternPiece> AllPatPieces = new List <PatternPiece>();

            foreach (var item in _context.PatternPiece)
            {
                AllPatPieces.Add(item);
            }
            List <PatPieceStyle> PPSwithThisStyle = new List <PatPieceStyle>();

            foreach (var item in _context.PatPieceStyle.Where(x => x.StyleId == style.Id).ToList())
            {
                PPSwithThisStyle.Add(item);
            }
            var model = new PatPieceViewModel
            {
                Style          = style,
                PatPieces      = AllPatPieces,
                PatPieceStyles = PPSwithThisStyle,
            };

            return(View(model));
        }
        // GET: PatternPieces/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var patternPiece = await _context.PatternPiece.SingleOrDefaultAsync(m => m.Id == id);

            if (patternPiece == null)
            {
                return(NotFound());
            }
            List <Style> allSty = new List <Style>();

            foreach (var item in _context.Style)
            {
                allSty.Add(item);
            }
            List <Variation> allVar = new List <Variation>();

            foreach (var item in _context.Variation)
            {
                allVar.Add(item);
            }
            List <PatPieceStyle> PPS = new List <PatPieceStyle>();

            foreach (var item in _context.PatPieceStyle)
            {
                PPS.Add(item);
            }
            List <PatPieceVariation> PPV = new List <PatPieceVariation>();

            foreach (var item in _context.PatPieceVariation)
            {
                PPV.Add(item);
            }
            var model = new PatPieceViewModel
            {
                PatternPiece       = patternPiece,
                PatPieceStyles     = PPS,
                PatPieceVariations = PPV,
                Styles             = allSty,
                Variations         = allVar
            };

            return(View(model));
        }