Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CompanyType,CategoryType,AddedFeatures")] FuturisticApproach futuristicApproach)
        {
            if (id != futuristicApproach.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(futuristicApproach);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FuturisticApproachExists(futuristicApproach.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryType"] = new SelectList(_context.Categories, "Category1", "Category1", futuristicApproach.CategoryType);
            ViewData["CompanyType"]  = new SelectList(_context.Companies, "Name", "Name", futuristicApproach.CompanyType);
            return(View(futuristicApproach));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,CompanyType,CategoryType,AddedFeatures")] FuturisticApproach futuristicApproach)
        {
            if (ModelState.IsValid)
            {
                _context.Add(futuristicApproach);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryType"] = new SelectList(_context.Categories, "Category1", "Category1", futuristicApproach.CategoryType);
            ViewData["CompanyType"]  = new SelectList(_context.Companies, "Name", "Name", futuristicApproach.CompanyType);
            return(View(futuristicApproach));
        }