public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var checkMedical = imedicalsResponsitory.GetAllWithoutTracking().Where(p => p.HospitalId.Equals(id)).Count();
                if (checkMedical > 0)
                {
                    return(Json(new[] { new
                                        {
                                            status = false,
                                            error = "This company has some medical data on it, so please delete the medical before deleting this company",
                                        } }));
                }

                await icompanyDetailsResponsitory.Delete(id);

                return(Json(new[] { new
                                    {
                                        status = true,
                                    } }));
            }
            catch (Exception e)
            {
                return(Json(new[] { new
                                    {
                                        status = false,
                                        error = "Something went wrong, please contact the admin",
                                    } }));
            }
        }
        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
                                } }));
        }