Exemple #1
0
        public void Render(SortedPagedCollection <Person, PersonSortCriteria> data)
        {
            this.RenderMenuOptions(data);

            var option = this.WaitForUserOptionInput();

            this.HandleUserOption(option);
        }
Exemple #2
0
        public void Render(SortedPagedCollection <Person, PersonSortCriteria> data)
        {
            Console.Clear();

            ConsoleHelper.WriteSectionForCollection(
                $"Person listing (page {data.PageIndex + 1} of {data.TotalPagesCount})",
                $"(sort criteria: {GetSortCriteriaString(data.SortCriteria)}, {GetSortDirectionString(data.SortDirection)})",
                data.Data,
                p => Console.WriteLine($"#{p.Id.ToFixedWidthString(5)} {p.FullName.ToFixedWidthString(25)} {p.DateOfBirth:yyyy-MM-dd}"),
                () => Console.WriteLine("(no persons)"));
        }
Exemple #3
0
        private void LoadDataForCurrentPage()
        {
            var personBO = new PersonBusinessObject(this.personRepository);

            this.data = personBO.GetPersonsPaged(this.pageIndex, this.pageSize, this.sortCriteria, this.sortDirection);

            if (this.pageIndex > data.GetLastPageIndex())
            {
                this.pageIndex = data.GetLastPageIndex();

                this.data = personBO.GetPersonsPaged(this.pageIndex, this.pageSize, this.sortCriteria, this.sortDirection);
            }

            this.personListingView.Render(this.data);

            this.menuView.Render(this.data);
        }
Exemple #4
0
        private void RenderMenuOptions(SortedPagedCollection <Person, PersonSortCriteria> data)
        {
            var optionsBuilder = new StringBuilder();

            optionsBuilder.AppendLine("Use one of the following options to continue:");

            optionsBuilder.AppendLine($"- To go to first page: type '{Options.FirstPage}'");

            if (data.CanGoPreviousPage())
            {
                optionsBuilder.AppendLine($"- To go to previous page: type '{Options.PreviousPage}'");
            }

            if (data.CanGoNextPage())
            {
                optionsBuilder.AppendLine($"- To go to next page: type '{Options.NextPage}'");
            }

            optionsBuilder.AppendLine($"- To go to last page: type '{Options.LastPage}'");

            if ((data.SortCriteria != PersonSortCriteria.ById) || ((data.SortCriteria == PersonSortCriteria.ById) && (data.SortDirection == SortDirection.Descending)))
            {
                optionsBuilder.AppendLine($"- To change sort to be by person's Id ascending: type '{Options.SortByIdAsc}'");
            }

            if ((data.SortCriteria != PersonSortCriteria.ById) || ((data.SortCriteria == PersonSortCriteria.ById) && (data.SortDirection == SortDirection.Ascending)))
            {
                optionsBuilder.AppendLine($"- To change sort to be by person's Id descending: type '{Options.SortByIdDesc}'");
            }

            if ((data.SortCriteria != PersonSortCriteria.ByFirstName) || ((data.SortCriteria == PersonSortCriteria.ByFirstName) && (data.SortDirection == SortDirection.Descending)))
            {
                optionsBuilder.AppendLine($"- To change sort to be by person's FistName ascending: type '{Options.SortByFirstNameAsc}'");
            }

            if ((data.SortCriteria != PersonSortCriteria.ByFirstName) || ((data.SortCriteria == PersonSortCriteria.ByFirstName) && (data.SortDirection == SortDirection.Ascending)))
            {
                optionsBuilder.AppendLine($"- To change sort to be by person's FistName descending: type '{Options.SortByFirstNameDesc}'");
            }

            if ((data.SortCriteria != PersonSortCriteria.ByLastName) || ((data.SortCriteria == PersonSortCriteria.ByLastName) && (data.SortDirection == SortDirection.Descending)))
            {
                optionsBuilder.AppendLine($"- To change sort to be by person's LastName ascending: type '{Options.SortByLastNameAsc}'");
            }

            if ((data.SortCriteria != PersonSortCriteria.ByLastName) || ((data.SortCriteria == PersonSortCriteria.ByLastName) && (data.SortDirection == SortDirection.Ascending)))
            {
                optionsBuilder.AppendLine($"- To change sort to be by person's LastName descending: type '{Options.SortByLastNameDesc}'");
            }

            if ((data.SortCriteria != PersonSortCriteria.ByBirthDate) || ((data.SortCriteria == PersonSortCriteria.ByBirthDate) && (data.SortDirection == SortDirection.Descending)))
            {
                optionsBuilder.AppendLine($"- To change sort to be by person's BirthDate ascending: type '{Options.SortByBirthDateAsc}'");
            }

            if ((data.SortCriteria != PersonSortCriteria.ByBirthDate) || ((data.SortCriteria == PersonSortCriteria.ByBirthDate) && (data.SortDirection == SortDirection.Ascending)))
            {
                optionsBuilder.AppendLine($"- To change sort to be by person's BirthDate descending: type '{Options.SortByBirthDateDesc}'");
            }

            optionsBuilder.AppendLine($"- To exit: type '{Options.Exit}'");

            optionsBuilder.Append("Your option is = ");

            Console.Write(optionsBuilder.ToString());
        }