public async Task <IActionResult> Create([Bind("Id,ControllerId,ActionTitle,ActionName")] AuthAction authAction) { if (ModelState.IsValid) { _context.Add(authAction); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(authAction)); }
public async Task <IActionResult> Create([Bind("Id,CountryId,StateId,CityName,City3Code,City2Code,Status")] City city) { if (ModelState.IsValid) { _context.Add(city); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(city)); }
public async Task <IActionResult> Create([Bind("Id,CountryId,StateName,State3Code,State2Code,Ordering,Status")] State state) { if (ModelState.IsValid) { _context.Add(state); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(state)); }
public async Task <IActionResult> Create([Bind("Id,CompanyName,Address,Email,Phone")] Company company) { if (ModelState.IsValid) { _context.Add(company); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(company)); }
//public async Task<IActionResult> Edit(int? id) public async Task <IActionResult> Authentication(int?id) { if (id == null) { return(NotFound()); } var role = await _context.Role.FirstOrDefaultAsync(m => m.Id == id); if (role == null) { return(NotFound()); } ViewData["RoleId"] = id; ViewData["RoleName"] = role.RoleName; //check and insert all actions var Actions = await _context.AuthAction .Join( _context.AuthController, action => action.ControllerId, controller => controller.Id, (action, controller) => new { Id = action.Id, ControllerName = controller.ControllerName, ControllerId = action.ControllerId, ActionTitle = action.ActionTitle, ActionName = action.ActionName } ).ToListAsync(); foreach (var item in Actions) { var TotalCount = _context.Auth .Where(e => e.RoleId == id) .Where(e => e.ControllerName == item.ControllerName) .Where(e => e.ActionName == item.ActionName).Count(); if (TotalCount <= 0) { var author = new Auth { RoleId = Convert.ToInt32(id), ControllerName = item.ControllerName, ActionName = item.ActionName, ActionTitle = item.ActionTitle, Access = "No" }; _context.Add(author); _context.SaveChanges(); } } var controllers = await _context.AuthController.ToListAsync(); ViewData["returndata"] = ""; foreach (var item in controllers) { var ActhList = await _context.Auth .Where(e => e.RoleId == id) .Where(e => e.ControllerName == item.ControllerName).ToListAsync(); ViewData["returndata"] += "<div class='card card-outline card-primary collapsed-card'>"; ViewData["returndata"] += "<div class='card-header'>"; ViewData["returndata"] += "<h3 class='card-title'>" + item.Title + "</h3>"; ViewData["returndata"] += "<div class='card-tools'>"; ViewData["returndata"] += "<button type = 'button' class='btn btn-tool' data-card-widget='collapse'><i class='fas fa-plus'></i></button>"; ViewData["returndata"] += "</div>"; ViewData["returndata"] += "</div>"; ViewData["returndata"] += "<div class='card-body' style='display: none;'>"; ViewData["returndata"] += "<table class='table table-bordered'>"; ViewData["returndata"] += "<thead>"; ViewData["returndata"] += "<tr>"; ViewData["returndata"] += "<th>Action</th>"; ViewData["returndata"] += "<th>Access</th>"; ViewData["returndata"] += "</tr>"; ViewData["returndata"] += "</thead>"; ViewData["returndata"] += "<tbody>"; foreach (var items in ActhList) { ViewData["returndata"] += "<tr>"; ViewData["returndata"] += "<td>" + items.ActionTitle + "</td>"; ViewData["returndata"] += "<td>" + items.Access + "</td>"; ViewData["returndata"] += "</tr>"; } ViewData["returndata"] += "</tbody>"; ViewData["returndata"] += "</table>"; ViewData["returndata"] += "</div>"; ViewData["returndata"] += "</div>"; } return(View(role)); }