public ActionResult Details(int id, string name, string content, int?categoryId, GridSortOptions gridSortOptions,
                                    [DefaultValue(1)] int page)
        {
            // Pobranie użytkownika po identyfikatorze
            var provider = _providerRepo.GetServiceProviderById(id);

            // Pobranie listy firm danego  użytkownika
            var companiesList = _companyRepo.GetCompaniesByUserId(provider.UserId);

            // Ustawienie domyślnej kolumny sortowania
            if (string.IsNullOrWhiteSpace(gridSortOptions.Column))
            {
                gridSortOptions.Column = "Id";
            }

            // Filtrowanie po kategorii firmy
            if (categoryId.HasValue)
            {
                companiesList = companiesList.Where(a => a.CategoryId == categoryId);
            }

            // Filtrowanie po nazwie firmy
            if (!string.IsNullOrWhiteSpace(name))
            {
                companiesList = companiesList.Where(a => a.Name.Contains(name));
            }

            // Filtrowanie po opisie firmy
            if (!string.IsNullOrWhiteSpace(content))
            {
                companiesList = companiesList.Where(a => a.Description.Contains(content));
            }

            // Utworzenie modelu do filtrowania firm
            var companiesFilterViewModel = new CompanyFilteredViewModel();

            companiesFilterViewModel.SelectedCategoryId = categoryId ?? -1;
            companiesFilterViewModel.Fill();

            // Stronicowanie i sortowanie listy firm
            var companiesPagedList = companiesList.OrderBy(gridSortOptions.Column, gridSortOptions.Direction)
                                     .AsPagination(page, 10);

            var companiesListContainer = new CompanyListContainerViewModel
            {
                CompanyPagedList         = companiesPagedList,
                CompanyFilteredViewModel = companiesFilterViewModel,
                GridSortOptions          = gridSortOptions
            };

            var serviceProviderCompaniesListContainer = new ServiceProviderCompaniesListContainerViewModel
            {
                Companies       = companiesListContainer,
                ServiceProvider = provider,
            };

            return(View(serviceProviderCompaniesListContainer));
        }
        public ActionResult Edit(int id)
        {
            ServiceProvider serviceProvider = _serviceProviderRepo.GetServiceProviderById(id);

            //using Microsoft.AspNet.Identity;
            if (serviceProvider.UserId == User.Identity.GetUserId() || User.IsInRole("administrator"))
            {
                return(View(serviceProvider));
            }

            TempData["Error"] = "Nie masz uprawnień do edytowania tego usługodawcy!";
            return(RedirectToAction("Index"));
        }