public async Task <IActionResult> Edit(int id, [Bind("Id,RoleId,ControllerName,Retrive,Insert,Update,Delete")] AuthenticModel authenticModel) { if (id != authenticModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(authenticModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuthenticModelExists(authenticModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(authenticModel)); }
public async Task <IActionResult> Create([Bind("Id,RoleId,ControllerName,Retrive,Insert,Update,Delete")] AuthenticModel authenticModel) { if (ModelState.IsValid) { var authentic = await _context.AuthenticModel.FirstOrDefaultAsync(m => m.RoleId == authenticModel.RoleId && m.ControllerName == authenticModel.ControllerName); if (authentic == null) { _context.Add(authenticModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(RedirectToAction(nameof(Create))); }