Exemplo n.º 1
0
 public static void AddFacilityAdmin(User assigner, string userid, Faculties fac)
 {
     if (assigner.isSystemAdmin)
     {
         SystemAdmin admin = new SystemAdmin(assigner);
         admin.AddFacilityAdmin(userid, fac);
     }
     else
     {
         throw new FaultException<SException>(new SException(),
             new FaultReason("You do not have the permission to perform this task!"));
     }
 }
Exemplo n.º 2
0
        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!"));

            }
        }
Exemplo n.º 3
0
        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!"));

            }
        }
Exemplo n.º 4
0
        public static bool AddFacilityAdmin(SystemAdmin assigner, string useridToAssign, Faculties f)
        {
            if (assigner.UserID == useridToAssign)
            {
                throw new FaultException<SException>(new SException(),
                    new FaultReason("You cannot Remove your own role!"));
            }
            else
            {
                RemoveAllRoles(useridToAssign); //Remove existing role
                DAL dalDataContext = new DAL();
                try
                {
                    FacilityAdmin fa = (from facAdm in dalDataContext.facAdmins
                                        where facAdm.Faculty == f
                                        select facAdm).FirstOrDefault<FacilityAdmin>();

                    if (fa == null)
                    {
                        Table<FacilityAdmin> sTable = dalDataContext.facAdmins;
                        fa = new FacilityAdmin(useridToAssign, f);
                        sTable.InsertOnSubmit(fa);
                        sTable.Context.SubmitChanges();
                    }
                    else
                    {
                        fa.UserID = useridToAssign;
                        dalDataContext.SubmitChanges();
                    }

                    string msg = assigner.Name + " has assigned you to the role of Facility Admin for " +
                         f.ToString().Replace("_", " ");

                    string title = "You have been Added to the System Group - Facility Administrator";

                    NotificationController.sendNotification(assigner.UserID, useridToAssign, 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!"));
                }
            }
        }
Exemplo n.º 5
0
 public static void RemoveRole(User assigner, string userid)
 {
     if (assigner.UserID == userid)
     {
         throw new FaultException<SException>(new SException(),
             new FaultReason("You cannot Remove your own role!"));
     }
     else  if (assigner.isSystemAdmin)
     {
         SystemAdmin admin = new SystemAdmin(assigner);
         admin.RemoveRole(userid);
     }
     else
     {
         throw new FaultException<SException>(new SException(),
             new FaultReason("You do not have the permission to perform this task!"));
     }
 }