public static void RemoveDeptHeadRoleFromUser(string fullname, string depid) { string username = DisbursementLogic.GetUserName(fullname, depid); Roles.RemoveUserFromRole(username, "HOD"); Roles.AddUserToRole(username, "Employee"); }
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); } } }