Ejemplo n.º 1
0
        public ActionResult ProjectForAccount()
        {
            var loginUser = cookiemanagement.GetCoockieAustetication();



            List <ProjectModel> projectModels = new List <ProjectModel>();



            ViewBag.MyProject       = pm.getAll().Where(x => x.CreatorAccount == loginUser).ToList();
            ViewBag.SignedUpProject = pm.getSignedUpProject(loginUser);



            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Index(int[] Compentecey, int[] CategoryFilter, DateTime?dataCreate, int?id, int?Competence, int?Category, int pageIndex = 1, string progetto = "", string parolachiave = "", string autore = "")
        {
            List <ProjectModel> getList = new List <ProjectModel>();

            getList = pm.getAll();


            if (progetto != ViewBag.Progetto)
            {
                ViewBag.Progetto = progetto;
            }

            if (progetto != "")
            {
                getList = getList.Where(x => x.Title.Contains(progetto)).ToList();
            }



            if (parolachiave != ViewBag.Descrizione)
            {
                ViewBag.Descrizione = parolachiave;
            }
            if (parolachiave != "")
            {
                getList = getList.Where(x => x.Description.Contains(parolachiave)).ToList();
            }



            if (autore != ViewBag.Autore)
            {
                ViewBag.Autore = autore;
            }
            if (autore != "")
            {
                getList = getList.Where(x => x.CreatorAccount.Contains(autore)).ToList();
            }



            if (dataCreate != ViewBag.DataCreate)
            {
                ViewBag.DataCreate = dataCreate;
            }
            if (dataCreate != null)
            {
                getList = getList.Where(x => x.Date == dataCreate).ToList();
            }



            ViewBag.ListCompetence = cm.getAll();

            if (Compentecey != null)
            {
                foreach (var item in ViewBag.ListCompetence)
                {
                    if (Compentecey.Any(x => x == item.CompetenceID))
                    {
                        item.Selected = true;
                    }
                }


                foreach (var item in Compentecey)
                {
                    getList = getList.Where(x => x.Competences.Any(y => y.CompetenceID == item)).ToList();
                }
            }



            ViewBag.ListCategory = categoryM.getAll();

            if (CategoryFilter != null)
            {
                foreach (var item in ViewBag.ListCategory)
                {
                    if (CategoryFilter.Any(x => x == item.CategoryID))
                    {
                        item.Selected = true;
                    }
                }


                foreach (var item in CategoryFilter)
                {
                    getList = getList.Where(x => x.Categories.Any(y => y.CategoryID == item)).ToList();
                }
            }



            if (id != 0 && id != null)
            {
                getList = getList.Where(x => x.ProjectID == id).ToList();
            }

            if (Category != null)
            {
                var idToDelete = new List <int>();


                foreach (var item in getList)
                {
                    var dss = item.Categories.FirstOrDefault(x => x.CategoryID == Category);
                    if (dss == null)
                    {
                        idToDelete.Add(item.ProjectID);
                    }
                }

                foreach (var item in idToDelete)
                {
                    var idelete = getList.First(x => x.ProjectID == item);
                    getList.Remove(idelete);
                }
            }



            if (Competence != null)
            {
                var idToDelete = new List <int>();


                foreach (var item in getList)
                {
                    var dss = item.Competences.FirstOrDefault(x => x.CompetenceID == Competence);
                    if (dss == null)
                    {
                        idToDelete.Add(item.ProjectID);
                    }
                }

                foreach (var item in idToDelete)
                {
                    var idelete = getList.First(x => x.ProjectID == item);
                    getList.Remove(idelete);
                }
            }



            int pageSize = 6;

            ViewBag.PageIndex = pageIndex;
            var totalItems = getList.Count();
            var totalPages = (totalItems / pageSize) + 1;

            if (totalItems % pageSize == 0)
            {
                totalPages--;
            }

            ViewBag.TotalPages = totalPages;
            ViewBag.TotalItems = totalItems;

            return(View(getList.Skip(pageSize * (pageIndex - 1)).Take(pageSize)));
        }