public void CreatePermission(ActionsDto permission) { var action = new Actions(permission.Area, permission.Controller, permission.Action, permission.Description, permission.CreatedBy); this._actionRepository.Add(action); }
public async Task <Actions> AddActions(ActionsDto actionDto) { var mapped = _mapper.Map <Actions>(actionDto); await _context.Actions.AddAsync(mapped); await _context.SaveChangesAsync(); return(mapped); }
public void ModifyPermission(ActionsDto permission) { var action = this._actionRepository.GetByKey(permission.ID); if (action != null) { action.Update(permission.Area, permission.Controller, permission.Action, permission.Description, permission.UpdatedBy); this._actionRepository.Update(action); } }
public ActionResult EditPermission(ActionsDto model) { model.UpdatedBy = this.LoginUser.Identity.Name; try { using (var service = ServiceLocator.Instance.Resolve <IMenuPermissionService>()) { service.ModifyPermission(model); } } catch (Exception) { return(Json(false, "Modify the permission failure.")); } return(Json(true)); }
public ActionResult AttachPermissionToRole(ActionsDto model, Guid[] roles) { var handler = this.LoginUser.Identity.Name; try { using (var service = ServiceLocator.Instance.Resolve <IMenuPermissionService>()) { service.AttachPermissionToRoles(model.ID, roles, handler); } } catch (Exception) { return(Json(false, "Attach the permission to roles failure.")); } return(Json(true)); }
public ActionResult AttachPermissionToRole(Guid permissionId) { // find all roles. // find the roles that include to the permission. using (var roleService = ServiceLocator.Instance.Resolve <IRoleService>()) using (var permissionService = ServiceLocator.Instance.Resolve <IMenuPermissionService>()) { var roles = roleService.FindAllRoles(); var rolesOfPermission = permissionService.FindRolesOfPermission(permissionId); ViewBag.Roles = roles; ViewBag.RolesOfPermission = rolesOfPermission; var model = new ActionsDto { ID = permissionId }; return(PartialView(model)); } }
public async Task <IActionResult> AddAction(ActionsDto actionsDto) { var createdAction = await _repo.AddActions(actionsDto); return(Ok(createdAction)); }