public static void RemoveDeptHeadRoleFromUser(string fullname, string depid)
        {
            string username = DisbursementLogic.GetUserName(fullname, depid);

            Roles.RemoveUserFromRole(username, "HOD");
            Roles.AddUserToRole(username, "Employee");
        }
Example #2
0
        public static List <string> ListCollectionPointsWithTime()
        {
            List <CollectionPoint> cpList = new List <CollectionPoint>();

            cpList = DisbursementLogic.ListCollectionPoints();
            List <string> cpWithTimeList = new List <string>();

            foreach (CollectionPoint C in cpList)
            {
                string s = C.CollectionPoint1;
                cpWithTimeList.Add(s);
            }
            return(cpWithTimeList);
        }
        public static void CancelDelegate(DDelegateDetail dDelegateinput)
        {
            using (SA45Team12AD entities = new SA45Team12AD())
            {
                DDelegateDetail dDelegate = entities.DDelegateDetails.Where(p => p.DepartmentHeadDelegate == dDelegateinput.DepartmentHeadDelegate).Where(x => x.DepartmentID == dDelegateinput.DepartmentID).Where(x => x.StartDate == dDelegateinput.StartDate).Where(x => x.EndDate == dDelegateinput.EndDate).First();
                if (dDelegateinput.StartDate >= DateTime.Today)
                {
                    dDelegate.StartDate = DateTime.Today.AddDays(-1);
                }
                dDelegate.EndDate = DateTime.Today.AddDays(-1);

                Department department = entities.Departments.Where(x => x.DeptID == dDelegateinput.DepartmentID).First();

                department.HasDelegate = 0;
                entities.SaveChanges();
                if (Roles.IsUserInRole(DisbursementLogic.GetUserName(dDelegateinput.DepartmentHeadDelegate, dDelegateinput.DepartmentID), "HOD"))
                {
                    RemoveDeptHeadRoleFromUser(dDelegate.DepartmentHeadDelegate, dDelegate.DepartmentID);
                }
            }
        }