public ActionResult CreateRole(RoleModelView obj) { RoleLogic rl = new RoleLogic(); rl.AddRole(obj.Name); return(RedirectToAction("GetallRole")); }
internal bool UpgradeArchitectureToRemote(out Exception ex) { ex = null; int errCount = 0; try { Architecture a = this.CurrentArchitecture; List <KellRole.Action> atcs = a.Acts; List <Department> deps = a.Deps; List <Module> mods = a.Mods; List <Permission> perms = a.Pers; List <Role> roles = a.Roles; List <UserGroup> ugrps = a.Ugroups; List <User> users = a.Users; ActionLogic.GetInstance().UpgradeList(atcs); DepartmentLogic.GetInstance().UpgradeList(deps); ModuleLogic.GetInstance().UpgradeList(mods); PermissionLogic.GetInstance().UpgradeList(perms); RoleLogic.GetInstance().UpgradeList(roles); UserGroupLogic.GetInstance().UpgradeList(ugrps); UserLogic.GetInstance().UpgradeList(users); } catch (Exception e) { errCount++; ex = e; } return(errCount == 0); }
private void btnconfirm_Click(object sender, EventArgs e) ///Add role into database { RoleLogic Logic = new RoleLogic(); string rolename = txtbxrolename.Text; Role r = new Role(rolename, 1); if (txtbxrolename.TextLength > 0) { MessageBox.Show("Rol '" + r.RetrieveRoleName() + "' aangemaakt"); if (Logic.AddRole(r) == true) { var overview = new RoleOverview(email); this.Hide(); overview.Show(); } else { MessageBox.Show("Er ging iets mis tijdens het toevoegen van de rol"); } } if (txtbxrolename.TextLength == 0) ///Checks if rolename is not null { MessageBox.Show("Rolnaam kan niet leeg zijn!"); } }
public override string[] GetUsersInRole(string roleName) { RoleLogic roleLogic = new RoleLogic(System.Web.Hosting.HostingEnvironment.MapPath("~/Data/roles.txt")); roleLogic.LoadData(); return(roleLogic.GetUsersInRole(roleName)); }
public static List <SelectListItem> PopulateRoleSelectListItem() { try { RoleLogic roleLogic = new RoleLogic(); List <ROLE> roles = roleLogic.GetEntitiesBy(r => r.Active); if (roles == null || roles.Count <= 0) { return(new List <SelectListItem>()); } List <SelectListItem> roleList = new List <SelectListItem>(); SelectListItem list = new SelectListItem(); list.Value = ""; list.Text = Select; roleList.Add(list); foreach (ROLE role in roles) { SelectListItem selectList = new SelectListItem(); selectList.Value = role.Id.ToString(); selectList.Text = role.Name; roleList.Add(selectList); } return(roleList); } catch (Exception) { throw; } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, Id = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { RoleLogic rl = new RoleLogic(); rl.AddRole("Client"); AddUserToRole(model.Email, "Client"); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
private void btn_roles_Click(object sender, EventArgs e) { UserLogic userLogic = new UserLogic(); RoleLogic roleLogic = new RoleLogic(); SingleUser singleUser = new SingleUser(); PermissionRepository PermissionRepo = new PermissionRepository(new PermissionContext()); var AllRoles = roleLogic.RetrieveAllRoles(); int pagePermission = 20; User user; user = new User(email); userLogic.GetSingleUser(user); bool hasPagePermission = PermissionRepo.CheckPermissionsFromRole(user.RetrieveRoleID(), pagePermission); if (hasPagePermission == true) { this.Hide(); var roles = new RoleOverview(email); roles.Closed += (s, args) => this.Close(); roles.Show(); } else { MessageBox.Show("U heeft hier de rechten niet voor!"); } }
private void btnEditRole_Click(object sender, EventArgs e) { UserLogic userLogic = new UserLogic(); RoleLogic roleLogic = new RoleLogic(); PortalLogin Login = new PortalLogin(); SingleUser singleUser = new SingleUser(); var AllRoles = roleLogic.RetrieveAllRoles(); User U = new User(email); userLogic.GetSingleUser(U); if (U.RoleName == "Admin") { if (lbxRoles.SelectedIndex > -1) { foreach (var OneRole in AllRoles) { if (OneRole.RetrieveRoleName() == lbxRoles.SelectedItem.ToString()) { rolestring = Convert.ToString(lbxRoles.SelectedItem); this.Hide(); SingleRole SingleRole = new SingleRole(OneRole.RetrieveRoleID(), rolestring, email); SingleRole.Show(); } } } } else { MessageBox.Show("U heeft hier de permissies niet voor!"); } }
public override bool IsUserInRole(string username, string roleName) { RoleLogic roleLogic = new RoleLogic(System.Web.Hosting.HostingEnvironment.MapPath("~/Data/roles.txt")); roleLogic.LoadData(); return(roleLogic.IsUserInRole(username, roleName)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int roleID = (int)value; var modules = RoleLogic.ModuleProcessOfRole(roleID); return(RoleVM.ChangeSysModuleToTreeItem(modules)); }
public async Task <Role> Post([FromBody] Role role) { CheckNullBody(role); var roleLogic = new RoleLogic(Cache, Context); return(await roleLogic.AddRole(role)); }
public UtilisateurController() { userLogic = new UtilisateurLogic(); companyLogic = new CompanyLogic(); roleLogic = new RoleLogic(); notifLogic = new NotificationLogic(); mailLogic = new MailLogic(); }
public FormUser(UserLogic userLogic, RoleLogic roleLogic, GroupLogic groupLogic) { InitializeComponent(); this.userLogic = userLogic; this.roleLogic = roleLogic; this.groupLogic = groupLogic; }
public async Task <Page <Role> > Grid([FromBody] GridRequest gridRequest) { CheckNullBody(gridRequest); var roleLogic = new RoleLogic(Cache, Context); return(await roleLogic.GetGrid(gridRequest)); }
public ProfileController() { userLogic = new UtilisateurLogic(); companyLogic = new CompanyLogic(); roleLogic = new RoleLogic(); passwordResetTokenLogic = new PasswordResetTokenLogic(); notificationLogic = new NotificationLogic(); }
public AccountController() { utilisateurLogic = new UtilisateurLogic(); passwordResetTokenLogic = new PasswordResetTokenLogic(); roleLogic = new RoleLogic(); notifLogic = new NotificationLogic(); mailLogic = new MailLogic(); }
public IHttpActionResult GetForAuthenticate() { var identity = (ClaimsIdentity)User.Identity; var roles = identity.Claims.Where(c => c.Type == ClaimTypes.Role) .Select(c => c.Value); return(Ok(RoleLogic.GetRoleByName(string.Join(",", roles.ToList())))); }
public async Task <Role> Put(int id, [FromBody] Role role) { CheckNullBody(role); role.RoleId = id; var roleLogic = new RoleLogic(Cache, Context); return(await roleLogic.UpdateRole(role)); }
public void AddPermission() { RoleLogic RLogic = new RoleLogic(); PermissionLogic PLogic = new PermissionLogic(); string selectedPermission = lbxPermissions.SelectedItem.ToString(); string selectedRole = cmbRoles.SelectedItem.ToString(); PLogic.AddPermission(selectedRole, selectedPermission); }
/// <summary> /// Get all roles from database and insert into listbox /// </summary> public void LoadRoles() { RoleLogic Logic = new RoleLogic(); List <Role> Roles = Logic.RetrieveAllRoles(); foreach (Role role in Roles) { lbxRoles.Items.Add(role.RetrieveRoleName()); } }
public User AddUser(string name, string email, string password, string token, string phone) { string hashPassword = HashPassword(password, password); var roleLogic = new RoleLogic(); var newUser = new User(); var newTeam = new Team(); var currencyLogic = new CurrencyLogic(); var newUserTeamLink = new UserTeamLink(); byte[] time = BitConverter.GetBytes(DateTime.UtcNow.ToBinary()); byte[] key = Guid.NewGuid().ToByteArray(); string newToken = Convert.ToBase64String(time.Concat(key).ToArray()); var defaultUserRole = roleLogic.GetRole(Roles.User); var defautCurrency = currencyLogic.GetCurrencyByCode("HUF"); using (var db = new TimeTrackerModelContainer()) { var userInDb = db.User.FirstOrDefault(x => x.Email == email); if (userInDb != null) { throw new Exception("Ez az Email cím már regisztrált"); } newUser.Name = name; newUser.Email = email; newUser.Password = hashPassword; newUser.Phone = phone; newUser.Token = newToken; newUser.Role = defaultUserRole; db.Role.Attach(newUser.Role); db.User.Add(newUser); newTeam.Name = newUser.Name; db.Team.Add(newTeam); newUserTeamLink.User = newUser; newUserTeamLink.Currency = defautCurrency; newUserTeamLink.PrivatePrice = "0"; newUserTeamLink.PublicPrice = "0"; newUserTeamLink.Team = newTeam; db.Currency.Attach(newUserTeamLink.Currency); db.UserTeamLink.Add(newUserTeamLink); db.SaveChanges(); } return(newUser); }
public void generateRoles() { RoleLogic rl = new RoleLogic(); var roles = rl.Getall(); var roleList = roles.Select(x => new SelectListItem() { Text = x.Name, Value = x.Name }); ViewBag.Roles = roleList; }
/// <summary> /// Fill the listbox with all the roles that are in the database /// </summary> public void FillUserRoles() { RoleLogic Logic = new RoleLogic(); var AllRoles = Logic.RetrieveAllRoles(); foreach (var SingleRole in AllRoles) { CB_Roles.Items.Add(SingleRole.RetrieveRoleName()); } }
public Staff GetStaffByLoginName(string loginName) { Staff staff = new Staff(); currentPeriodDb = new CurrentPeriodDb(); int periodId = 0; DataSet dsCurrentPeriod = currentPeriodDb.SelectAllCurrentPeriod(); if (dsCurrentPeriod != null) { periodId = Convert.ToInt32(dsCurrentPeriod.Tables[0].Rows[0][currentPeriodDb.FIELD_PERIOD_ID]); } if (periodId <= 0) { throw new Exception("No current period exist in the system! Please contact your system administrator."); } DataSet dsStaff = staffDb.SelectStaffByLoginName(loginName, periodId); if (dsStaff != null) { if (dsStaff.Tables[0].Rows.Count > 0) { staff.Id = Convert.ToString(dsStaff.Tables[0].Rows[0][staffDb.FIELD_STAFF_ID]); staff.Name = Convert.ToString(dsStaff.Tables[0].Rows[0]["Name"]); staff.LoginName = Convert.ToString(dsStaff.Tables[0].Rows[0][staffDb.FIELD_LOGIN_NAME]); staff.Email = Convert.ToString(dsStaff.Tables[0].Rows[0][staffDb.FIELD_EMAIL]); staff.Company.Name = Convert.ToString(dsStaff.Tables[0].Rows[0]["Company_Name"]); staff.Department.Name = Convert.ToString(dsStaff.Tables[0].Rows[0]["Department_Name"]); staff.JobRole.Id = Convert.ToInt32(dsStaff.Tables[0].Rows[0]["Job_Role_ID"]); staff.JobRole.Name = Convert.ToString(dsStaff.Tables[0].Rows[0]["Job_Role_Name"]); staff.Level.Name = Convert.ToString(dsStaff.Tables[0].Rows[0]["Job_Role_Level_Name"]); staff.Level.Id = Convert.ToString(dsStaff.Tables[0].Rows[0]["Job_Role_Level_ID"]); staff.CompanyDepartmentJobRoleId = Convert.ToInt32(dsStaff.Tables[0].Rows[0][staffDb.FIELD_COMPANY_DEPARTMENT_JOB_ROLE_ID]); staff.Location.Name = Convert.ToString(dsStaff.Tables[0].Rows[0][staffDb.FIELD_LOCATION_NAME]); staff.MetricsCount = metricDbFacade.CountMetrics(staff.CompanyDepartmentJobRoleId, periodId); staff.IsActive = Convert.ToBoolean(dsStaff.Tables[0].Rows[0]["Is_Active"]); staff.Role = new Role(); staff.Role.Id = Convert.ToInt32(dsStaff.Tables[0].Rows[0]["Role_Id"]); RoleLogic roleLogic = new RoleLogic(); staff.Role = roleLogic.Get(staff); staff.FormatNameToPascalCasing(); return(staff); } } return(null); }
public UserController(IWebHostEnvironment env, UserLogic userLogic, ImageLogic imageLogic, RoleLogic roleLogic, DepartmentLogic departmentLogic) { _env = env; _userLogic = userLogic; _imageLogic = imageLogic; _roleLogic = roleLogic; _departmentLogic = departmentLogic; }
private void btnRemove_Click(object sender, EventArgs e) { //Get the rolename and the permissionname string RoleName = cmbRoles.SelectedItem.ToString(); string PermissionName = listBox1.SelectedItem.ToString(); //New instance of permissionlogic and rolelogic PermissionLogic PLogic = new PermissionLogic(); RoleLogic RLogic = new RoleLogic(); //New role and new permisson Role r = new Role(RoleName, 1); Permission p = new Permission(1, PermissionName); //Empt roleid and permissionid int RoleID = 0; int PermissionID = 0; //Get permissionid from the database var AllPermissions = PLogic.RetrieveAllPermissions(); foreach (var SinglePermission in AllPermissions) { if (SinglePermission.PermissionName == p.PermissionName) { PermissionID = SinglePermission.RetrievePermissionID(); } } //Get roleid from the database var AllRoles = RLogic.RetrieveAllRoles(); foreach (var SingleRole in AllRoles) { if (SingleRole.RetrieveRoleName() == r.RetrieveRoleName()) { RoleID = SingleRole.RetrieveRoleID(); } } PLogic.DeleteRolePermission(RoleID, PermissionID); listBox1.Items.Clear(); string rol = cmbRoles.SelectedItem.ToString(); List <string> permissions = PLogic.GetAllRolePermissions(rol); foreach (string per in permissions) { listBox1.Items.Add(per); } }
private async Task GiveUserRoles(int userId) { var roleLogic = new RoleLogic(Cache, UserContext); var roles = await roleLogic.GetAutoRoles(); var userRoleUpdater = new UserRoleUpdater(Cache, UserContext); foreach (var role in roles) { await userRoleUpdater.AddRoleToUser(new UserRole { RoleId = role.RoleId, UserId = userId }); } }
public RequestBookingController() { requestBookingLogic = new RequestBookingLogic(); bookingLogic = new BookingLogic(); statusLogic = new StatusLogic(); addressLogic = new AdressLogic(); utilisateurLogic = new UtilisateurLogic(); userBookingLogic = new UserBookingLogic(); stopOverAddressLogic = new StopOverAddressLogic(); stopOverLogic = new StopOverLogic(); notificationLogic = new NotificationLogic(); roleLogic = new RoleLogic(); }
private static Architecture GetRemoteArchitecture() { Architecture a = Architecture.Empty; a.Deps = DepartmentLogic.GetInstance().GetAllDepartments(); a.Ugroups = UserGroupLogic.GetInstance().GetAllUserGroups(); a.Users = UserLogic.GetInstance().GetAllUsers(); a.Mods = ModuleLogic.GetInstance().GetAllModules(); a.Acts = ActionLogic.GetInstance().GetAllActions(); a.Pers = PermissionLogic.GetInstance().GetAllPermissions(); a.Roles = RoleLogic.GetInstance().GetAllRoles(); return(a); }
private void BindModuleTree(SysRole role) { if (myRadDataForm.Mode == RadDataFormMode.Edit) { var modules = RoleLogic.ModuleProcessOfRole(role.ID); RadTreeView tv = this.GetMPTreeView(); IList mtis = tv.ItemsSource as IList; foreach (ModuleTreeItem mti in mtis) { SetChildrenModulesChecked(modules, mti, tv); } tv.CollapseAll();//设置好之后全部收缩 } }