public async Task <IActionResult> Edit(int id, [Bind("Id,Slug,Name,Description,ParentId")] Models.Attribute attribute) { if (id != attribute.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(attribute); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AttributeExists(attribute.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ParentId"] = new SelectList(_context.Attributes, "Id", "Name", attribute.ParentId); return(View(attribute)); }
public async Task <IActionResult> Create([Bind("Id,Slug,Name,Description,ParentId")] Models.Attribute attribute) { if (ModelState.IsValid) { _context.Add(attribute); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(attribute)); }