public IActionResult Index()
        {
            List <ProjectViewModel> projectList = new List <ProjectViewModel>();
            var projects = _context.Projects.Include(x => x.Company).ThenInclude(x => x.Entrepreneur).ThenInclude(x => x.Country);

            foreach (var item in projects)
            {
                var projectViewModel = new ProjectViewModel
                {
                    Id               = item.Id,
                    Image            = item.Image1,
                    Name             = item.Name,
                    ProjectTitle     = item.ProjectTitle,
                    ShortDescription = item.ProjectShortDescription,
                    EntreprenuerName = item.Company.Entrepreneur.FName + " " + item.Company.Entrepreneur.LName,
                    PledgedAmount    = item.NeededFund,
                    DaysLeft         = Math.Floor((item.EndingDate - DateTime.Now).TotalDays),
                    CompanyName      = item.Company.Name,
                    CountryName      = item.Company.Entrepreneur.Country.Name,
                    Funded           = _fundedAmount.FundedAmount(item.Id),
                    Image2           = item.Image2,
                    Image3           = item.Image3,
                    EntreprenuerId   = item.Company.Entrepreneur.Id
                };
                projectList.Add(projectViewModel);
            }


            return(View(projectList.OrderByDescending(x => x.Id)));
        }
        public IActionResult Search(string keyword, int page)
        {
            int numberOfContent = 12;

            var projectItems = _context.Projects
                               .Where(x => x.Name.Contains(keyword) || x.Company.Name.Contains(keyword) || x.ProjectShortDescription.Contains(keyword) || x.ProjectCategory.Type.Contains(keyword))
                               .Include(x => x.ProjectCategory)
                               .Include(x => x.Company)
                               .ThenInclude(x => x.Entrepreneur)
                               .ThenInclude(x => x.Country)
                               .OrderByDescending(x => x.Id);

            int numberOfPage = projectItems.Count() / numberOfContent;

            List <ProjectViewModel> projectList = new List <ProjectViewModel>();

            var projects = projectItems
                           .Skip((page - 1) * numberOfContent)
                           .Take(numberOfContent).ToList();

            foreach (var item in projects)
            {
                var projectViewModel = new ProjectViewModel
                {
                    Id               = item.Id,
                    Image            = item.Image1,
                    Name             = item.Name,
                    ProjectTitle     = item.ProjectTitle,
                    ShortDescription = item.ProjectShortDescription,
                    EntreprenuerName = item.Company.Entrepreneur.FName + " " + item.Company.Entrepreneur.LName,
                    PledgedAmount    = item.NeededFund,
                    DaysLeft         = Math.Floor((item.EndingDate - DateTime.Now).TotalDays),
                    CompanyName      = item.Company.Name,
                    CountryName      = item.Company.Entrepreneur.Country.Name,
                    Funded           = _fundedAmount.FundedAmount(item.Id),
                    Image2           = item.Image2,
                    Image3           = item.Image3
                };
                projectList.Add(projectViewModel);
            }

            ViewData["NumberOfPage"] = numberOfPage;
            ViewData["Keyword"]      = keyword;
            ViewData["Country"]      = new SelectList(_context.Countries, "Id", "Name");
            ViewData["SortedBy"]     = new SelectList(_context.Countries, "Id", "Name");
            return(View(projectList));
        }