예제 #1
0
        private void AscendingClicked(string obj)
        {
            List <ChildRecord> reorderedList = new List <ChildRecord>();

            if (obj.Equals("NameAscending"))
            {
                var list = ChildRecords.OrderBy(a => a.LastName);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("DOBAscending"))
            {
                var list = ChildRecords.OrderBy(a => a.DOBDateField);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("LocationAscending"))
            {
                var list = ChildRecords.OrderBy(a => a.Location);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("EnrollmentAscending"))
            {
                var list = ChildRecords.OrderBy(a => a.EnrollmentDateField);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("ChildAscendingDecending"))
            {
                bool isAscending = (ChildRecords.SequenceEqual(ChildRecords.OrderBy(a => a.ChildID))) ? true : false;
                reorderedList = isAscending ? new List <ChildRecord>(ChildRecords.OrderByDescending(a => a.ChildID)) : new List <ChildRecord>(ChildRecords.OrderBy(a => a.ChildID));
            }
            ChildRecords.Clear();
            ChildRecords = reorderedList;
        }