Esempio n. 1
0
        public IActionResult CatalogEditor(int catalogId)
        {
            var catalog = catalogId > 0 ? _catalogService.Get(catalogId) : new Catalog();

            if (catalog == null)
            {
                return(NotFound());
            }
            var catalogModel    = _catalogModelFactory.Create(catalog);
            var stores          = _storeService.Get(x => true).ToList();
            var catalogStoreIds = catalog.Stores?.Select(x => x.Id).ToList() ?? new List <int>();
            var availableStores = SelectListHelper.GetSelectItemList(stores, x => x.Id, x => x.Name)
                                  .Select(x =>
            {
                if (catalogStoreIds.Any(y => y.ToString() == x.Value))
                {
                    x.Selected = true;
                }
                return(x);
            }).ToList();

            return(R.Success.With("catalog", catalogModel).With("availableStores", availableStores).Result);
        }