Example #1
0
 public FrameworksViewModel(bool isFrameworkDeveloper, bool isFrameworkContributor, MyFrameworksViewModel myFrameworksViewModel, AllFrameworksViewModel allFrameworksViewModel)
 {
     IsFrameworkDeveloper   = isFrameworkDeveloper;
     IsFrameworkContributor = isFrameworkContributor;
     MyFrameworksViewModel  = myFrameworksViewModel;
     AllFrameworksViewModel = allFrameworksViewModel;
 }
Example #2
0
        public void ViewFrameworks_All_action_should_return_view_result()
        {
            // Given
            var dashboardFrameworks = new[]
            {
                FrameworksHelper.CreateDefaultBrandedFramework(),
                FrameworksHelper.CreateDefaultBrandedFramework(),
                FrameworksHelper.CreateDefaultBrandedFramework(),
            };

            A.CallTo(() => frameworkService.GetAllFrameworks(AdminId)).Returns(dashboardFrameworks);
            SearchSortFilterAndPaginateTestHelper
            .GivenACallToSearchSortFilterPaginateServiceReturnsResult <BrandedFramework>(
                searchSortFilterPaginateService
                );

            // When
            var result = controller.ViewFrameworks();

            // Then
            var allFrameworksViewModel = new AllFrameworksViewModel(
                new SearchSortFilterPaginationResult <BrandedFramework>(
                    new PaginationResult <BrandedFramework>(dashboardFrameworks, 1, 1, 12, 3, true),
                    null,
                    "FrameworkName",
                    "Ascending",
                    null
                    )
                );
            var myFrameworksViewModel = new MyFrameworksViewModel(
                new SearchSortFilterPaginationResult <BrandedFramework>(
                    new PaginationResult <BrandedFramework>(new List <BrandedFramework>(), 1, 1, 12, 0, true),
                    null,
                    "FrameworkName",
                    "Ascending",
                    null
                    ),
                true
                );
            var expectedModel = new FrameworksViewModel(
                true,
                false,
                myFrameworksViewModel,
                allFrameworksViewModel,
                FrameworksTab.AllFrameworks
                );

            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
Example #3
0
        public void ViewFrameworks_All_action_should_return_view_result()
        {
            // Given
            var dashboardFrameworks = new[]
            {
                FrameworksHelper.CreateDefaultBrandedFramework(),
                FrameworksHelper.CreateDefaultBrandedFramework(),
                FrameworksHelper.CreateDefaultBrandedFramework()
            };

            A.CallTo(() => frameworkService.GetAllFrameworks(AdminId)).Returns(dashboardFrameworks);

            // When
            var result = controller.ViewFrameworks();

            // Then
            var allFrameworksViewModel = new AllFrameworksViewModel(
                dashboardFrameworks,
                null,
                "FrameworkName",
                "Ascending",
                1
                );
            var myFrameworksViewModel = new MyFrameworksViewModel(
                new List <BrandedFramework>(),
                null,
                "FrameworkName",
                "Ascending",
                1,
                true);
            var expectedModel = new FrameworksViewModel(
                true,
                false,
                myFrameworksViewModel,
                allFrameworksViewModel
                );

            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
Example #4
0
        public IActionResult ViewFrameworks(string?searchString  = null,
                                            string?sortBy        = null,
                                            string sortDirection = BaseSearchablePageViewModel.Ascending,
                                            int page             = 1,
                                            string tabname       = "All")
        {
            sortBy ??= FrameworkSortByOptions.FrameworkName.PropertyName;
            var adminId = GetAdminId();
            var isFrameworkDeveloper   = GetIsFrameworkDeveloper();
            var isFrameworkContributor = GetIsFrameworkContributor();
            IEnumerable <BrandedFramework> frameworks;

            if (tabname == "All")
            {
                frameworks = frameworkService.GetAllFrameworks(adminId);
            }
            else
            {
                if (!isFrameworkDeveloper && !isFrameworkContributor)
                {
                    return(RedirectToAction("ViewFrameworks", "Frameworks", new { tabname = "All" }));
                }
                frameworks = frameworkService.GetFrameworksForAdminId(adminId);
            }
            MyFrameworksViewModel  myFrameworksViewModel;
            AllFrameworksViewModel allFrameworksViewModel;

            if (tabname == "All")
            {
                myFrameworksViewModel = new MyFrameworksViewModel(
                    new List <BrandedFramework>(),
                    searchString,
                    sortBy,
                    sortDirection,
                    page,
                    isFrameworkDeveloper);
                allFrameworksViewModel = new AllFrameworksViewModel(
                    frameworks,
                    searchString,
                    sortBy,
                    sortDirection,
                    page);
            }
            else
            {
                myFrameworksViewModel = new MyFrameworksViewModel(
                    frameworks,
                    searchString,
                    sortBy,
                    sortDirection,
                    page,
                    isFrameworkDeveloper);
                allFrameworksViewModel = new AllFrameworksViewModel(
                    new List <BrandedFramework>(),
                    searchString,
                    sortBy,
                    sortDirection,
                    page);
            }
            var frameworksViewModel = new FrameworksViewModel(
                isFrameworkDeveloper,
                isFrameworkContributor,
                myFrameworksViewModel,
                allFrameworksViewModel
                );

            return(View("Developer/Frameworks", frameworksViewModel));
        }
Example #5
0
        public IActionResult ViewFrameworks(string?searchString  = null,
                                            string?sortBy        = null,
                                            string sortDirection = GenericSortingHelper.Ascending,
                                            int page             = 1,
                                            string tabname       = "All")
        {
            sortBy ??= FrameworkSortByOptions.FrameworkName.PropertyName;
            var adminId = GetAdminId();
            var isFrameworkDeveloper   = GetIsFrameworkDeveloper();
            var isFrameworkContributor = GetIsFrameworkContributor();
            IEnumerable <BrandedFramework> frameworks;

            if (tabname == "All")
            {
                frameworks = frameworkService.GetAllFrameworks(adminId);
            }
            else
            {
                if (!isFrameworkDeveloper && !isFrameworkContributor)
                {
                    return(RedirectToAction("ViewFrameworks", "Frameworks", new { tabname = "All" }));
                }
                frameworks = frameworkService.GetFrameworksForAdminId(adminId);
            }
            MyFrameworksViewModel  myFrameworksViewModel;
            AllFrameworksViewModel allFrameworksViewModel;

            var searchSortPaginateOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString, 60),
                new SortOptions(sortBy, sortDirection),
                null,
                new PaginationOptions(page, 12)
                );

            if (tabname == "All")
            {
                var myFrameworksResult = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                    new List <BrandedFramework>(),
                    searchSortPaginateOptions
                    );
                myFrameworksViewModel = new MyFrameworksViewModel(myFrameworksResult, isFrameworkDeveloper);
                var allFrameworksResult = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                    frameworks,
                    searchSortPaginateOptions
                    );
                allFrameworksViewModel = new AllFrameworksViewModel(allFrameworksResult);
            }
            else
            {
                var myFrameworksResult = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                    frameworks,
                    searchSortPaginateOptions
                    );
                myFrameworksViewModel = new MyFrameworksViewModel(myFrameworksResult, isFrameworkDeveloper);
                var allFrameworksResult = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                    new List <BrandedFramework>(),
                    searchSortPaginateOptions
                    );
                allFrameworksViewModel = new AllFrameworksViewModel(allFrameworksResult);
            }

            var currentTab          = tabname == "All" ? FrameworksTab.AllFrameworks : FrameworksTab.MyFrameworks;
            var frameworksViewModel = new FrameworksViewModel(
                isFrameworkDeveloper,
                isFrameworkContributor,
                myFrameworksViewModel,
                allFrameworksViewModel,
                currentTab
                );

            return(View("Developer/Frameworks", frameworksViewModel));
        }