private void Start() { if (IsRegistration()) { try { UserManagement userManagement = new UserManagement(); if (userManagement.IsFirstUser()) { var regForm = new Views.Registration(); regForm.ShowDialog(); var regVM = (Views.RegistrationViewModel)regForm.DataContext; if (regVM.UserCreated != null) { Helpers.UserLogin = regVM.UserCreated; if (!userManagement.IsRoleExist("Administrator").Result) { userManagement.AddNewRole("Administrator"); } if (!userManagement.IsRoleExist("Manager").Result) { userManagement.AddNewRole("Manager"); } if (!userManagement.IsRoleExist("Admin").Result) { userManagement.AddNewRole("Admin"); } if (!userManagement.IsRoleExist("Operational").Result) { userManagement.AddNewRole("Operational"); } if (!userManagement.IsRoleExist("Accounting").Result) { userManagement.AddNewRole("Accounting"); } userManagement.AddUserInRole(Helpers.UserLogin.Id, "Administrator"); var setting = new Views.Setting(); setting.ShowDialog(); } } } catch (Exception ex) { Helpers.ShowErrorMessage(ex.Message); this.Close(); } } else { this.Close(); } }
private void Item_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var item = (role)sender; if (item.Selected) { context.AddUserInRole(UserSelected.Id, item.Name); } else { context.RemoveUserInRole(UserSelected.Id, item.Name); } }