public async Task <IActionResult> ShowDetail(int id)
        {
            var employee = await iemployeesResponsitory.GetById(id);

            var policies = ipoliciesOnEmployeesResponsitory.GetAll().Where(p => p.EmpId.Equals(id)).ToList();

            ViewBag.policies = policies;
            return(View("detail", employee));
        }
        public IActionResult Index()
        {
            var id = int.Parse(HttpContext.Session.GetString("userId"));

            ViewBag.emppolicies = ipoliciesOnEmployeesResponsitory.GetAll().Where(p => p.EmpId.Equals(id)).OrderBy(p => p.StatusId).ToList();
            return(View());
        }
示例#3
0
        public IActionResult Index()
        {
            ViewBag.pageTitle = "Wellcome " + HttpContext.Session.GetString("userName");
            var id = int.Parse(HttpContext.Session.GetString("userId"));

            ViewBag.emppolicies = ipoliciesOnEmployeesResponsitory.GetAll().Where(p => p.EmpId.Equals(id)).OrderBy(p => p.StatusId).ToList();
            ViewBag.polRequests = ipolicyRequestDetailsResponsitory.GetAll().Where(p => p.EmpId.Equals(id)).OrderBy(p => p.Status).ToList();
            return(View());
        }
        public IActionResult ShowData(int fromNum, int limitNum, string searchData)
        {
            var policiesList           = new List <PoliciesOnEmployees>();
            var policiesListGetAllData = new List <PoliciesOnEmployees>();

            if (searchData != "" && searchData != null)
            {
                policiesListGetAllData = ipoliciesOnEmployeesResponsitory.GetAllWithoutTracking().Where(p => p.Emp.FirstName.Contains(searchData)).ToList();
                policiesList           = ipoliciesOnEmployeesResponsitory.GetAll().Where(p => p.Emp.FirstName.Contains(searchData)).OrderBy(p => p.StatusId).ThenBy(p => p.Emp.FirstName).Skip(fromNum).Take(limitNum).ToList();
            }
            else
            {
                policiesListGetAllData = ipoliciesOnEmployeesResponsitory.GetAllWithoutTracking().ToList();
                policiesList           = ipoliciesOnEmployeesResponsitory.GetAll().OrderBy(p => p.StatusId).ThenBy(p => p.Emp.FirstName).Skip(fromNum).Take(limitNum).ToList();
            }

            var html  = "";
            var count = 0;

            foreach (var policy in policiesList)
            {
                var color = "green";
                if (policy.StatusId == 1)
                {
                    color = "orange";
                }
                else if (policy.StatusId == 4 || policy.StatusId == 3)
                {
                    color = "red";
                }
                count++;
                var colorBackground = "";
                if (count % 2 == 0)
                {
                    colorBackground = "style='background-color:#7bedd1'";
                }
                html += "<tr class='tr-shadow' " + colorBackground + ">" +
                        "<td>" + count + "</td>" +
                        "<td>" + policy.Emp.FirstName + "</td>" +
                        "<td>" + policy.Emp.LastName + "</td>" +
                        "<td>" + policy.Policy.PolicyName + "</td>" +
                        "<td>" + policy.Policy.Medical.MedicalName + "</td>" +
                        "<td>" + policy.Policy.Medical.Hospital.HospitalName + "</td>" +
                        "<td>" + policy.Policy.Medical.Company.CompanyName + "</td>" +
                        "<td style='color:" + color + "; font-weight:bold'>" + policy.Status.StatusName + "</td>" +
                        "<td><a href='#' onclick='getDetail(" + policy.Id.ToString() + ")' style='font-weight:bold;'>View Detail</a> | ";
                if (policy.StatusId == 1)
                {
                    html += "<a href='#' onclick='acceptedBtn(" + policy.Id.ToString() + ")' style='font-weight:bold;color:green'>Accepted</a>" +
                            " | <a href='#' style='color:red;font-weight:bold' id='blockBtn' onclick='deniedBtn(" + policy.Id.ToString() + ")'>Block</a>" +
                            "</td></tr>";
                }
                else if (policy.StatusId == 2)
                {
                    html += "<a href='#' style='color:red;font-weight:bold' id='blockBtn' onclick='deniedBtn(" + policy.Id.ToString() + ")'>Block</a>" +
                            "</td></tr>";
                }
                else
                {
                    html += "<a href='#' onclick='acceptedBtn(" + policy.Id.ToString() + ")' style='font-weight:bold;color:green'>Accepted</a></td></tr>";
                }
                if (count < policiesList.Count())
                {
                    html += "</tr><tr class='spacer'></tr>";
                }
            }

            var totalPage = 0;

            if (policiesListGetAllData.Count() % 5 == 0)
            {
                totalPage = policiesListGetAllData.Count() / 5;
            }
            else
            {
                totalPage = (policiesListGetAllData.Count() / 5) + 1;
            }
            if (totalPage == 0)
            {
                totalPage = 1;
            }

            return(Json(new[] { new
                                {
                                    status = true,
                                    data = html,
                                    pageTotal = totalPage
                                } }));
        }