예제 #1
0
        public ActionResult exSearch(PostedItems postedItems)
        {
            string id             = (string)Session["itemTypeSession"];
            var    model          = new Search();
            var    selectedItems  = new List <checkBoxListModel>();
            var    selectedCards  = new List <cards>();
            var    postedItemsIds = new string[0];
            var    availItems     = new List <checkBoxListModel>();

            if (postedItems == null)
            {
                postedItems = new PostedItems();
            }

            if (postedItems.IDs != null && postedItems.IDs.Any())
            {
                postedItemsIds = postedItems.IDs;
            }
            if (postedItemsIds.Any())
            {
                selectedCards = applicationDAO.cardsForExtandedSearchList(postedItems.IDs, id).Where(cd => cd.published == true).Distinct().ToList();
                var claimsQuery = applicationDAO.selectedItemsForExtandedSearch(postedItems.IDs).ToList();
                int c           = 0;
                foreach (var i in claimsQuery)
                {
                    selectedItems.Add(new checkBoxListModel(c, i.ClaimValue, i.ClaimType));
                }
            }
            else
            {
                selectedCards = applicationDAO.getItemLayouts(id).Where(c => c.published == true).ToList();
            }



            var claims = applicationDAO.getAllCardClaims().Where(c => c.published == true);
            int count  = 0;

            foreach (var item in claims)
            {
                if (item.ClaimType != "TYPE")
                {
                    availItems.Add(new checkBoxListModel(count, item.ClaimValue, item.ClaimType));
                }
                count++;
            }
            model.availItems           = availItems;
            model.selectedItems        = selectedItems;
            model.postedItems          = postedItems;
            model.Cards                = selectedCards;
            Session["itemTypeSession"] = id;
            return(View(model));
        }