internal async void Search(string text) { text = text.ToLower(); LabResultList.Clear(); if (String.IsNullOrEmpty(text)) { var loader = await MaterialDialog.Instance.LoadingDialogAsync("Loading .."); await Initilize(); await loader.DismissAsync(); } else { PageNumber = 1; var mainList = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates); var list = mainList.Where(s => s.ASREF.ToLower().Contains(text) || s.ASBRCH.ToLower().Contains(text) || s.ASYEAR.ToLower().Contains(text) || s.ASPATT.ToLower().Contains(text) || s.ASPATF.ToLower().Contains(text) || s.ASPATL.ToLower().Contains(text)); list.ForEach(s => LabResultList.Add(s)); }; }
public async Task Initilize() { try { UserDialogs.Instance.ShowLoading(); PageNumber = 1; CheckFilterIndex = 2; SortedIndex = 4; //var result = await ReportsService.GetLabReports(Constants.UserProfile.Role, Constants.UserProfile.LabID, "L", 1); var result = await ReportsService.GetAllLabReports(Constants.UserProfile.Role, Constants.UserProfile.LabID, "L", CalendarSelectedDates.StartDate, CalendarSelectedDates.EndDate); if (result.Success) { int unViewed = 0; foreach (var reportsModel in result.data) { //ReportViewedModel viewedModel = new ReportViewedModel //{ // ReportBrch = reportsModel.ASBRCH, // ReportRef = reportsModel.ASREF, // ReportYear = reportsModel.ASYEAR //}; //var data = Settings.LabortoryReportViewed; //if (data.Any(x => x.ReportBrch == reportsModel.ASBRCH && // x.ReportRef == reportsModel.ASREF && // x.ReportYear == reportsModel.ASYEAR)) //{ // reportsModel.IsViewed = true; //} bool isChecked = false; string checkedOn = String.Empty; switch (Constants.UserProfile.Role) { case "patient": isChecked = !String.IsNullOrEmpty(reportsModel.ASPCHKBY); checkedOn = reportsModel.ASPCHKDTE; reportsModel.IsViewed = !String.IsNullOrEmpty(reportsModel.ASPVIEWED); break; case "doctor": isChecked = !String.IsNullOrEmpty(reportsModel.ASDCHKBY); checkedOn = reportsModel.ASDCHKDTE; reportsModel.IsViewed = !String.IsNullOrEmpty(reportsModel.ASDVIEWED); break; case "agent": isChecked = !String.IsNullOrEmpty(reportsModel.ASACHKBY); checkedOn = reportsModel.ASACHKDTE; reportsModel.IsViewed = !String.IsNullOrEmpty(reportsModel.ASAVIEWED); break; case "guarantor": isChecked = !String.IsNullOrEmpty(reportsModel.ASGCHKBY); checkedOn = reportsModel.ASGCHKDTE; reportsModel.IsViewed = !String.IsNullOrEmpty(reportsModel.ASGVIEWED); break; } reportsModel.CheckedSource = isChecked ? "check.png" : "checkbox.png"; reportsModel.CheckDate = isChecked ? checkedOn : String.Empty; } LabResultListComplete = new ObservableCollection <ReportsModel>(result.data); var newList = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates); newList.ForEach(s => LabResultList.Add(s)); } } catch (Exception ex) { } finally { UserDialogs.Instance.HideLoading(); } }
public LabResultPageVM(INavigation _Nav) { Navigation = _Nav; CheckFilterIndex = -1; CalendarCommand = new DelegateCommand((s) => { CalendarVisibility = true; }); CheckFilterCommand = new DelegateCommand(async(s) => { try { var index = await ShowActionSheet("Filter", CheckReportsFilter.ToList());// await MaterialDialog.Instance.SelectActionAsync(CheckReportsFilter); if (index >= 0) { LabResultList.Clear(); PageNumber = 1; CheckFilterIndex = index; var list = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates); list.ForEach(a => LabResultList.Add(a)); FilterLabelText = SetFilterLabelText(CheckFilterIndex, CalendarSelectedDates); } } catch (Exception ex) { } }); SortCommand = new DelegateCommand(async(s) => { try { var index = await ShowActionSheet("Sort", SortDatesFilter.ToList());// await MaterialDialog.Instance.SelectActionAsync(SortDatesFilter); if (index >= 0) { LabResultList.Clear(); PageNumber = 1; SortedIndex = index; var list = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates); list.ForEach(a => LabResultList.Add(a)); } } catch (Exception ex) { } }); FilterCommand = new DelegateCommand(async(s) => { try { LabResultList.Clear(); await Initilize(); PageNumber = 1; var list = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates); list.ForEach(a => LabResultList.Add(a)); CalendarVisibility = false; FilterLabelText = SetFilterLabelText(CheckFilterIndex, CalendarSelectedDates); } catch (Exception ex) { } }); //CalendarSelectedDates.StartDate = DateTime.Now.AddMonths(2); //CalendarSelectedDates.EndDate = DateTime.Now; }