Ejemplo n.º 1
0
        public async Task <IActionResult> EditKnobNames(AllKnobsEditViewModel allKnobs)
        {
            if (ModelState.IsValid)
            {
                using (var db = _context)
                {
                    foreach (var item in allKnobs.Knobs)
                    {
                        db.Knob.Update(item);
                        await _context.SaveChangesAsync();
                    }

                    db.SaveChanges();
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(allKnobs));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> EditKnobNames(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AllKnobsEditViewModel allKnobs = new AllKnobsEditViewModel();
            var knobsToEdit = await _context.Knob
                              .Where(k => k.GearId == id).ToListAsync();

            var gearEditing = await _context.Gear
                              .FirstOrDefaultAsync(g => g.GearId == id);

            allKnobs.Gear  = gearEditing;
            allKnobs.Knobs = knobsToEdit;
            return(View(allKnobs));
        }