예제 #1
0
        public async void SearchClicked(string dob, string enrollmentDate)
        {
            var searchChildRecords = new List <ChildRecordsNewAssessment>();
            var isMorethan1000     = false;

            await LoadChildRecordsFromDBAsync();

            if (!string.IsNullOrEmpty(FirstName) || !string.IsNullOrEmpty(LastName) || (SelectedLocations != null && SelectedLocations.Any()) || !string.IsNullOrEmpty(dob) || !string.IsNullOrEmpty(enrollmentDate) || !string.IsNullOrEmpty(ChildID))
            {
                IEnumerable <ChildRecordsNewAssessment> query = ChildTestRecords;

                if (!string.IsNullOrEmpty(FirstName))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.FirstName) && p.FirstName.ToLower().Contains(FirstName.ToLower()));
                }
                if (!string.IsNullOrEmpty(LastName))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.LastName) && p.LastName.ToLower().Contains(LastName.ToLower()));
                }
                if (!string.IsNullOrEmpty(ChildID))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.ChildID) && p.ChildID.ToLower().Contains(ChildID.ToLower()));
                }
                if (!string.IsNullOrEmpty(dob))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.DOB) && p.DOB == dob);
                }
                if (!string.IsNullOrEmpty(enrollmentDate))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.Enrollment) && p.Enrollment == enrollmentDate);
                }
                if (SelectedLocations.Count > 0)
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.Location) && SelectedLocations.Contains(p.Location));
                }

                searchChildRecords = new List <ChildRecordsNewAssessment>(query);
            }
            else
            {
                searchChildRecords = ChildTestRecords;
            }


            if (!searchChildRecords.Any())
            {
                SearchResult       = ErrorMessages.RecordMatchesFoundMessage;
                SearchErrorColor   = Color.Red;
                SearchErrorVisible = true;
            }
            else
            {
                SearchResult       = string.Format(ErrorMessages.RecordsFoundMessage, searchChildRecords.Count(), searchChildRecords.Count() == 1 ? "Match" : "Matches");
                SearchErrorColor   = Color.Black;
                SearchErrorVisible = true;
                if (searchChildRecords.Count > 1000)
                {
                    isMorethan1000     = true;
                    SearchResult       = ErrorMessages.SearchError;
                    SearchErrorColor   = Color.Red;
                    SearchErrorVisible = true;
                }
                else if (searchChildRecords.Count > 5)
                {
                    searchChildRecords[searchChildRecords.Count - 1].IsTableSepartorVisble = false;
                }
                else
                {
                    searchChildRecords[searchChildRecords.Count - 1].IsTableSepartorVisble = true;
                    IsTableBottomLineVisible = false;
                }
                if (SelectAll)
                {
                    int index = 0;
                    foreach (var record in searchChildRecords)
                    {
                        index++;
                    }
                }
            }
            var list          = searchChildRecords.OrderBy(a => a.LastName);
            var reorderedList = new List <ChildRecordsNewAssessment>(list);

            ChildTestRecords.Clear();
            if (!isMorethan1000)
            {
                ChildTestRecords = reorderedList;
            }
        }
예제 #2
0
        /// <summary>
        /// Fetch child records
        /// </summary>
        public async void GetChildRecords()
        {
            int addedBy;

            if (ChildRecords.Any())
            {
                ChildRecords.Clear();
            }

            var initialChildRecords = new List <ChildRecord>();

            if (Application.Current.Properties.ContainsKey("UserID"))
            {
                var isSuccess = int.TryParse(Application.Current.Properties["UserID"].ToString(), out addedBy);
                if (isSuccess)
                {
                    var childRecords        = (_studentService.GetStudentsByOfflineID(addedBy));
                    var testRecords         = (_clinicalTestFormService.GetStudentTestForms()).Where(x => x.FormStatus != "Not started").Select(x => x.LocalStudentId).ToList();
                    var filteredChildRecord = childRecords.FindAll(x => testRecords.Contains(x.OfflineStudentID));
                    foreach (var childRecord in filteredChildRecord)
                    {
                        if (childRecord.SelectedLocationId.HasValue && AllLocations != null && AllLocations.Any() && AllLocations.Where(p => p.IsEnabled).Any(p => p.LocationId == childRecord.SelectedLocationId.Value))
                        {
                            string birthdate = (childRecord.Birthdate.Month < 10 ? "0" + childRecord.Birthdate.Month : childRecord.Birthdate.Month + "") + "/" + (childRecord.Birthdate.Day < 10 ? "0" + childRecord.Birthdate.Day : childRecord.Birthdate.Day + "") + "/" + childRecord.Birthdate.Year;
                            initialChildRecords.Add(new ChildRecord()
                            {
                                Name             = childRecord.FirstName + " " + childRecord.LastName,
                                selected         = false,
                                Location         = AllLocations != null && AllLocations.Any() && childRecord.SelectedLocationId != null ? AllLocations.FirstOrDefault(p => p.LocationId == childRecord.SelectedLocationId.Value)?.LocationName : "",
                                LocationID       = (childRecord.SelectedLocationId == null) ? 0 : Convert.ToInt32(childRecord.SelectedLocationId),
                                OfflineStudentId = childRecord.OfflineStudentID,
                                DOB = birthdate
                            });
                        }
                    }
                    var list = initialChildRecords.OrderBy(a => a.LastName);
                    initialChildRecords = new List <ChildRecord>(list);

                    var searchChildRecords          = new List <ChildRecord>();
                    IEnumerable <ChildRecord> query = initialChildRecords;

                    if (SelectedLocations.Count > 0)
                    {
                        query = query.Where(p => !string.IsNullOrEmpty(p.Location) && SelectedLocations.Contains(p.Location));
                    }

                    searchChildRecords = new List <ChildRecord>(query);
                    foreach (var item in searchChildRecords)
                    {
                        ChildRecords.Add(item);
                    }
                }
            }

            if (ChildRecords.Count == 0)
            {
                SelectedChild = "No results found";
                IsChildRecordButtonEnabled = false;
                IsBatteryTypeButtonEnabled = false;
            }
            else
            {
                SelectedChild = null;
            }
        }