コード例 #1
0
ファイル: KKPController.cs プロジェクト: koecrit/SKD_Pinere
        public ActionResult GetResultDataPasien(string search, string airline, string nomorPenerbangan, string namaPasien, string tanggalLahir, string rujukRS)
        {
            var dc = new PinereDataContext(PinereConstant.PinereConnectionString);
            List <SearchResult> ResultList = new List <SearchResult>();

            try
            {
                if (search == "True")
                {
                    var Result = (from a in dc.GetPasienList() select a);
                    if (!airline.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.AirlineId.Value.ToString() == airline);
                    }
                    if (!nomorPenerbangan.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.NomorPenerbangan.Contains(nomorPenerbangan));
                    }
                    if (!namaPasien.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.NamaPasien.Contains(namaPasien));
                    }
                    if (!tanggalLahir.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => DataRepository.GetDateStringFromDate(o.TanggalLahir) == tanggalLahir);
                    }
                    if (!rujukRS.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.Rujuk_RS.ToString() == rujukRS);
                    }

                    Result     = Result.OrderByDescending(o => o.KKPId);
                    ResultList = (from a in Result
                                  select new SearchResult
                    {
                        NamaAirline = a.NamaAirline,
                        NomorPenerbangan = a.NomorPenerbangan,
                        NamaPasien = a.NamaPasien,
                        TanggalLahir = DataRepository.GetDateStringFromDate(a.TanggalLahir),
                        HasilDiagnosa = a.Diagnosa,
                        RujukRS = a.Rujuk_RS_Dis,
                        ActionEdit = Url.Action("Edit", new { @KKPId = a.KKPId })
                    }).ToList();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(Json(new
            {
                iTotalRecords = ResultList.Count(),
                iTotalDisplayRecords = ResultList.Count(),
                aaData = ResultList
            }, JsonRequestBehavior.AllowGet));
        }