public void getRole()
        {
            string opl = System.Web.HttpContext.Current.User.Identity.Name.ToString();

            System.Web.HttpContext.Current.Session["swgId"] = swg;



            context = new EAF2Entities();

            var emp = context.Emps.FirstOrDefault(e => e.SWG == swg);


            if (emp != null)
            {
                var jobTitles = context.JobTitles.FirstOrDefault(j => j.JobId == emp.JobId
                                                                 &&
                                                                 (j.JobTitle1.Contains("manager") ||
                                                                  j.JobTitle1.Contains("Chief") ||
                                                                  j.JobTitle1.Contains("Director")));

                if (jobTitles != null)
                {
                    role = jobTitles.JobTitle1;
                    role = "Manager";
                }
                else
                {
                    string hrdIds = ConfigurationManager.AppSettings["HRDepartmentID"];

                    List <int> ids = hrdIds.Split(',').Select(int.Parse).ToList();

                    var hr = context.Emps.FirstOrDefault(e => ids.Contains(e.DeptId) && e.SWG == swg);

                    if (hr != null)
                    {
                        role = "HR";
                    }
                    else
                    {
                        role = null;
                    }
                }
            }

            if (role != null)
            {
                System.Web.HttpContext.Current.Session["role"] = role;
            }
        }
Beispiel #2
0
 public DepartmentsController()
 {
     context = new EAF2Entities();
 }
 public DisplayHRRequestsController()
 {
     context = new EAF2Entities();
 }
Beispiel #4
0
 public MyTeamController()
 {
     context = new EAF2Entities();
 }