/// <summary> /// This disables people's accounts for given account group /// </summary> /// <param name="personId"></param> /// <param name="accountGroupId"></param> public void DisableAccount(int personId, int accountGroupId) { var permission = MyPermissions.Single(x => x.Key.Id == accountGroupId).Value; if (permission == PermissionLevel.Admin || permission == PermissionLevel.SuperAdmin) { var targetPerson = GetMyColleagues(accountGroupId, true).Single(x => x.Id == personId); //there should be a simpler way to do this but i can't be effed var targetsPermission = targetPerson.GetPermissionLevel(accountGroupId); if (targetsPermission == PermissionLevel.SuperAdmin) { throw new UnauthorizedAccessException("You can't remove a superadmin"); } else if (targetsPermission == PermissionLevel.Admin && Me.GetPermissionLevel(accountGroupId) == PermissionLevel.Admin) { throw new UnauthorizedAccessException("You can't remove another admin user, only a superadmin can do that"); } var join = targetPerson.AccountGroupPeople.SingleOrDefault(x => x.AccountGroupId == accountGroupId); if (join != null) { Context.Delete <AccountGroupPerson>(join.Id); Context.SaveChanges(); } } else { throw new UnauthorizedAccessException("You lack permission to disable accounts"); } }
public static void ShowActionsPage(string pageMode = "", int staffID = 0) { if (pageMode == "" || pageMode == Amend) { pageMode = MyPermissions.Allow("EditActions") ? Amend : View; } ChangePage("ActionsPage.xaml?Mode=" + pageMode + ",StaffID=" + staffID.ToString()); }
protected AccountBasedManagement(IDatabaseContext context, int personId, int accountId) : base(context, personId) { var permission = MyPermissions.Single(x => x.Key.Id == accountId); AccountGroup = permission.Key; AccountGroupPermission = permission.Value; }
public static void ShowStageHistoryPage(string pageMode = "") { if (pageMode == "" || pageMode == Amend) { pageMode = MyPermissions.Allow("EditStageHistory") ? Amend : View; } ChangePage("StageHistoryPage.xaml?Mode=" + pageMode); }
public static void ShowTimelinePage(int projectID, string pageMode = "") { if (pageMode == "" || pageMode == Amend) { pageMode = MyPermissions.Allow("EditStageHistory") ? Amend : View; } ChangePage("TimelinePage.xaml?Mode=" + pageMode + ",ProjectID=" + projectID.ToString()); }
public static void ShowProjectPage(string pageMode, string sourcePage = "") { if (pageMode == PageFunctions.Amend && !MyPermissions.Allow("EditProjects")) { pageMode = PageFunctions.View; } ProjectSourcePage = (sourcePage != "") ? sourcePage : "ProjectPage"; ChangePage("ProjectPage.xaml?Mode=" + pageMode); }
public static void ShowClientProductsPage(int selectedProductID = 0) { string pageMode; // Mode is based on viewOnly or permissions; sourcePageMode tells us what the previous screen was if (ClientSourceMode == View) { pageMode = View; } else { pageMode = MyPermissions.Allow("EditClientProducts") ? Amend : View; } ChangePage("ClientProductsPage.xaml?Mode=" + pageMode + ",ProductID=" + selectedProductID.ToString()); }
public static void ShowStaffEntitiesPage(int selectedStaffID = 0, bool viewOnly = false, string sourcePageMode = "View") { string pageMode; // Mode is based on viewOnly or permissions; sourcePageMode tells us what the previous screen was if (viewOnly) { pageMode = View; } else { pageMode = MyPermissions.Allow("EditStaffEntities") ? Amend : View; } ChangePage("StaffEntitiesPage.xaml?Mode=" + pageMode + ",StaffID=" + selectedStaffID.ToString() + ",SourceMode=" + sourcePageMode); }
public static void ShowProjectDetailsPage(string pageMode = "") { if (pageMode == "") { if (ProjectSourceMode == View) { pageMode = View; } else { pageMode = MyPermissions.Allow("EditProjects") ? Amend : View; } } ChangePage("ProjectDetailsPage.xaml?Mode=" + pageMode); }
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults) { Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults); if (MyPermissions.OnRequestPermissionsResult(this, requestCode, grantResults) && !Alarm.IsInitFinished) { StartApp(); } else { MyPermissions.AlertRequestPermissionsWhenDenied(this, requestCode, permissions, grantResults); } base.OnRequestPermissionsResult(requestCode, permissions, grantResults); }
public static void ShowProjectContactsPage(string pageMode = "", int selectedContactID = 0, string sourcePage = "") { if (pageMode == "") { if (ProjectSourceMode == View) { pageMode = View; } else { pageMode = MyPermissions.Allow("EditClientTeams") ? Amend : View; } } if (sourcePage != "") { ProjectSourcePage = sourcePage; } ChangePage("ProjectContactsPage.xaml?Mode=" + pageMode + ",ContactID=" + selectedContactID.ToString()); }
private void StartApp() { if (SettingToneViewModel.IsFinding) { return; } if (Build.VERSION.SdkInt < BuildVersionCodes.M) { LoadAppAndRefreshAlarmManager(); return; } if (MyPermissions.Request_AudioPermission(this)) { if (MyPermissions.Request_StoragePermission(this)) { if (MyPermissions.Request_SystemAlertWindowPermission(this)) { LoadAppAndRefreshAlarmManager(); } } } }