Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("EcoscoreId,ObjectName,Description,Reuse,Reduce,Recycle,Photo,Ecoscore1")] EcoScore ecoScore)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ecoScore);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ecoScore));
        }
        public async Task <IActionResult> Create([Bind("UserId,FullName,ObjectName,Description,Reuse,Reduce,Recycle,Photo,Ecoscore,EcoscoreId")] UserSelection userSelection)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userSelection);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EcoscoreId"] = new SelectList(_context.EcoScore.OrderBy(c => c.EcoscoreId), "EcoscoreId", "EcoscoreId", userSelection.EcoscoreId);
            ViewData["objectName"] = new SelectList(_context.EcoScore, "objectName", "objectName", userSelection.ObjectName);
            return(View(userSelection));
        }