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

            ViewBag.medicals = imedicalsResponsitory.GetAll().OrderBy(p => p.MedicalName).ToList();
            return(View("detail", policy));
        }
        public IActionResult ShowData(int fromNum, int limitNum, string searchData)
        {
            var medicals           = new List <Medicals>();
            var medicalsGetAllData = new List <Medicals>();

            var companiesGetAllData = new List <CompanyDetails>();
            var companies           = new List <CompanyDetails>();

            if (searchData != "" && searchData != null)
            {
                medicalsGetAllData = imedicalsResponsitory.GetAllWithoutTracking().Where(p => p.MedicalName.Contains(searchData)).ToList();
                medicals           = imedicalsResponsitory.GetAll().OrderBy(p => p.MedicalName).Where(p => p.MedicalName.Contains(searchData)).Skip(fromNum).Take(limitNum).ToList();
            }
            else
            {
                medicalsGetAllData = imedicalsResponsitory.GetAllWithoutTracking().ToList();
                medicals           = imedicalsResponsitory.GetAll().OrderBy(p => p.MedicalName).Skip(fromNum).Take(limitNum).ToList();
            }

            var html  = "";
            var count = 0;

            foreach (var medical in medicals)
            {
                count++;
                var colorBackground = "";
                if (count % 2 == 0)
                {
                    colorBackground = "style='background-color:#7bedd1'";
                }
                html += "<tr class='tr-shadow' " + colorBackground + ">" +
                        "<td>" + count + "</td>" +
                        "<td>" + medical.MedicalName + "</td>" +
                        "<td>" + medical.MedicalDescription + "</td>" +
                        "<td>" + medical.Company.CompanyName + "</td>" +
                        "<td>" + medical.Hospital.HospitalName + "</td>" +
                        "<td>" +
                        "<a href='#' onclick='getDetail(" + medical.Id.ToString() + ")' style='font-weight:bold'>More Details</a>" +
                        "</td></tr>";
                if (count < medicals.Count())
                {
                    html += "</tr><tr class='spacer'></tr>";
                }
            }

            var totalPage = 0;

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

            return(Json(new[] { new
                                {
                                    status = true,
                                    data = html,
                                    pageTotal = totalPage
                                } }));
        }
Exemple #3
0
 public IActionResult Index(int id)
 {
     ViewBag.pageTitle = "Medicals provide by Company";
     ViewBag.medicals  = iMedicalsResponsitory.GetAll().Where(d => d.CompanyId.Equals(id)).ToList();
     return(View("Index"));
 }