public ActionResult Index()
        {
            string           MgrId = System.Web.HttpContext.Current.Session["swgId"] as String;
            LoginCredentials LG    = new LoginCredentials();

            LG.swg = System.Web.HttpContext.Current.Session["swgId"] as String;
            LG.getRole();
            System.Web.HttpContext.Current.Session["role"] = LG.role;
            if (System.Web.HttpContext.Current.Session["role"].ToString() == "null")
            {
                return(Content("Not Authorized User"));
            }
            //todoRK
            ViewBag.MgrId = MgrId;
            List <RequestData> rdl   = new List <RequestData>();
            string             query = @"WITH tree (SWG, name, level) AS (SELECT SWG, name, 1 as level FROM emp WHERE SWG = '" + LG.swg + "'  ) Select Requests.ReqId, JobTitle.JobTitle, Product.ProductName,Requests.Vacancies, Status.StatusValue, Requests.Criticality, Requests.StatusId,Emp.Name From Requests Inner Join JobTitle On Requests.JobId = JobTitle.JobId inner join Product on Requests.ProductID = Product.ProductID inner join Status on Requests.StatusId = Status.StatusId inner join tree on Requests.CreatedbyEmpId= tree.SWG  inner join RequestComments on Requests.ReqId= RequestComments.ReqId  inner join emp on RequestComments.EmpId = emp.Swg  where requestcomments.datetime=(select max(datetime) from requestcomments req2 where req2.reqid=requestcomments.reqid) and Requests.StatusId!=6 ORDER BY CONVERT(DateTime, Requests.lastmodifiedDate,101)  DESC";
            var obj = context.Database.SqlQuery <MyEntity>(query).ToList();

            foreach (var ob in obj)
            {
                RequestData rd = new RequestData();
                rd.SWGId       = LG.swg;
                rd.ReqId       = ob.ReqId;
                rd.JobTitle    = ob.JobTitle;
                rd.ProductName = ob.ProductName;
                rd.vacancies   = ob.Vacancies;
                rd.StatusValue = ob.StatusValue;
                rd.criticality = ob.criticality;
                if (rd.criticality == 1)
                {
                    rd.CriticalityName = "Normal";
                }
                else if (rd.criticality == 2)
                {
                    rd.CriticalityName = "Urgent";
                }
                rd.Status         = ob.StatusId;
                rd.LastReviewedBy = ob.Name;
                rdl.Add(rd);
            }
            //var data = BusinessComponents.Request.GetMyRequest(LG);
            ViewBag.Department = BusinessComponents.Request.DeptNames();
            ViewBag.pageInfo   = "MyRequests";
            System.Web.HttpContext.Current.Session["pageInfo"] = "MyRequests";
            ViewBag.IsSubmitted = false;
            return(View("Index", rdl));
        }
Exemplo n.º 2
0
 public static string role()
 {
     if (System.Web.HttpContext.Current.Session["role"] == null || String.IsNullOrEmpty(System.Web.HttpContext.Current.Session["role"].ToString()))
     {
         if (System.Web.HttpContext.Current.Session["swgId"] == null || String.IsNullOrEmpty(System.Web.HttpContext.Current.Session["swgId"].ToString()))
         {
             System.Web.HttpContext.Current.Session["swgId"] = System.Web.HttpContext.Current.User.Identity.Name.ToString();
         }
         LoginCredentials login = new LoginCredentials();
         login.swg = System.Web.HttpContext.Current.Session["swgId"].ToString();
         login.getRole();
         string condition = login.role;
         //BusinessComponents.Request.DepartmentId(System.Web.HttpContext.Current.User.Identity.Name.ToString());
         if (String.IsNullOrEmpty(condition))
         {
             System.Web.HttpContext.Current.Session["role"] = "null";
         }
         else
         {
             System.Web.HttpContext.Current.Session["role"] = condition;
         }
     }
     return(System.Web.HttpContext.Current.Session["role"].ToString());
 }