public static void AddRole(User assigner, SysRole sr) { if (assigner.isSystemAdmin) { SystemAdmin admin = new SystemAdmin(assigner); admin.AddRole(sr); } else { throw new FaultException<SException>(new SException(), new FaultReason("You do not have the permission to perform this task!")); } }
public static bool AddRole(SystemAdmin assigner, SysRole sr) { if (assigner.UserID == sr.UserID) { throw new FaultException<SException>(new SException(), new FaultReason("You cannot Remove your own role!")); } DAL dalDataContext = new DAL(); try { SysRole x = (from userRole in dalDataContext.sRole where userRole.UserID == sr.UserID select userRole).FirstOrDefault<SysRole>(); if (x == null) { Table<SysRole> sTable = dalDataContext.sRole; sTable.InsertOnSubmit(sr); sTable.Context.SubmitChanges(); } else { x.RoleLevel = sr.RoleLevel; x.Remarks = sr.Remarks; dalDataContext.SubmitChanges(); } string msg = assigner.Name + " has assigned you to the role of " + ((EnumRoles)sr.RoleLevel).ToString().Replace("_", " ") + Environment.NewLine + Environment.NewLine + "Remarks: " + sr.Remarks; string title = "You have been Added to the System Group - " + ((EnumRoles)sr.RoleLevel).ToString().Replace("_", " "); NotificationController.sendNotification(assigner.UserID, sr.UserID, title, msg); return true; } catch (Exception) { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured while the system is Adding the user's role, Please Try Again!")); } }
public static EnumRoles GetRole(string uid) { SysRole uRole = new SysRole(); if (isFacilityAdmin(uid)) { return EnumRoles.Facility_Admin; } DAL dalDataContext = new DAL(); uRole = (from userRole in dalDataContext.sRole where userRole.UserID == uid select userRole).FirstOrDefault<SysRole>(); if (uRole == null) { return EnumRoles.Nil; } else { return (EnumRoles)uRole.RoleLevel; } }
public bool AddRole(SysRole sr) { return SysAdminController.AddRole(this, sr); }
public void AssignEventOrganizer(User assigner, string userid, string description) { SysRole s = new SysRole(userid, EnumRoles.Event_Organizer, description); SysRoleController.AddRole(assigner, s); }
public void AssignSystemAdmin(User assigner, string userid, string description) { SysRole s = new SysRole(userid, EnumRoles.System_Admin, description); SysRoleController.AddRole(assigner, s); }