public ActionResult Create([Bind(Include = "Id,EmployeeFirstname,EmployeeLastname,PermissionType,PermissionDate")] Permissions permissions) { if (ModelState.IsValid) { _permissionsRepository.Create(permissions); return(RedirectToAction("List")); } ViewBag.PermissionType = new SelectList(_permissionTypeRepository.GetList(), "Id", "Description", permissions.PermissionTypes); return(View(permissions.Adapt <PermissionViewModel>())); }
public void AddPermissions() { #region List of Permissions Permission[] permissionsList = new Permission[19]; permissionsList[0] = new Permission() { Name = "User_View", Description = "Allows access to the User View" }; permissionsList[1] = new Permission() { Name = "User_Add", Description = "Allows access to the User Add" }; permissionsList[2] = new Permission() { Name = "User_Edit", Description = "Allows access to the User Edit" }; permissionsList[3] = new Permission() { Name = "User_Delete", Description = "Allows access to the User Delete" }; permissionsList[4] = new Permission() { Name = "Role_View", Description = "Allows access to the Role View" }; permissionsList[5] = new Permission() { Name = "Role_Edit", Description = "Allows access to the Role Edit" }; permissionsList[6] = new Permission() { Name = "Project_View", Description = "Allows access to the Project View" }; permissionsList[7] = new Permission() { Name = "Project_Add", Description = "Allows access to the Project Add" }; permissionsList[8] = new Permission() { Name = "Project_Edit", Description = "Allows access to the Project Edit" }; permissionsList[9] = new Permission() { Name = "Project_Archive", Description = "Allows access to the Project Archive" }; permissionsList[10] = new Permission() { Name = "Phase_View", Description = "Allows access to the Phase View" }; permissionsList[11] = new Permission() { Name = "Phase_Add", Description = "Allows access to the Phase Add" }; permissionsList[12] = new Permission() { Name = "Phase_Edit", Description = "Allows access to the Phase Edit" }; permissionsList[13] = new Permission() { Name = "Phase_Delete", Description = "Allows access to the Phase Delete" }; permissionsList[14] = new Permission() { Name = "Objective_View", Description = "Allows access to the Objective View" }; permissionsList[15] = new Permission() { Name = "Objective_Add", Description = "Allows access to the Objective Add" }; permissionsList[16] = new Permission() { Name = "Objective_Edit", Description = "Allows access to the Objective Edit" }; permissionsList[17] = new Permission() { Name = "Objective_Delete", Description = "Allows access to the Objective Delete" }; permissionsList[18] = new Permission() { Name = "ProjectTracking_View", Description = "Allows access to the ProjectTracking_View" }; #endregion // Save Permissions foreach (var item in permissionsList) { objPermission.Create(item); } PermissionRole permissionRole = new PermissionRole(); // Admin permissionRole.RoleID = 1; for (int i = 1; i <= permissionsList.Length; i++) { permissionRole.PermissionID = i; objPermissionRole.Create(permissionRole); } // PO permissionRole.RoleID = 2; for (int i = 7; i <= permissionsList.Length; i++) { permissionRole.PermissionID = i; objPermissionRole.Create(permissionRole); } // Client permissionRole.RoleID = 3; permissionRole.PermissionID = 19; objPermissionRole.Create(permissionRole); }