Exemplo n.º 1
0
        // todo: move to Data Service
        private TaxonomiesViewModel GetTermsModel(PostedTaxonomies postedTaxonomies)
        {
            MicaDAL.MicaRepository db = new MicaDAL.MicaRepository();
            // setup properties
            var model         = new TaxonomiesViewModel();
            var selectedTerms = new List <Term>();
            var postedTermIDs = new string[0];

            if (postedTaxonomies == null)
            {
                postedTaxonomies = new PostedTaxonomies();
            }

            // if an array of posted city ids exists and is not empty,
            // save selected ids
            //if (terms != null && terms.Any())
            //{
            //    postedTermIDs = terms;
            //    postedTerms.TermIDs = terms;
            //}
            // if a view model array of posted city ids exists and is not empty,
            // save selected ids
            //if (postedTerms.TermIDs != null && postedTerms.TermIDs.Any())
            //{
            //    postedTermIDs = postedTerms.TermIDs;
            //    model.WasPosted = true;
            //}
            // if there are any selected ids saved, create a list of taxonomies
            if (postedTermIDs.Any())
            {
                selectedTerms = db.GetMicaTerms(postedTaxonomies.TaxonomyIDs).ToList();
            }

            //.GetAll().Where(x => postedTaxonomyIDs.Any(s => x.Id.ToString().Equals(s))).ToList();

            // setup a view model
            model.AvailableTerms = db.GetMicaTerms(postedTaxonomies.TaxonomyIDs).ToList();
            model.SelectedTerms  = selectedTerms;
            //model.PostedTerms = postedTerms;

            return(model);
        }
Exemplo n.º 2
0
        public ActionResult TaxonomyPost(string[] taxonomies, PostedTaxonomies postedTaxonomies)
        {
            TaxonomiesViewModel tvm = GetTermsModel(postedTaxonomies);

            return(View("TermIndex", tvm));
        }