コード例 #1
0
        public async Task <IActionResult> Index()
        {
            ViewBag.AttributeCategories = _attributeService.GetAllAttributes();

            ManageAttributesViewModel mavm = new ManageAttributesViewModel()
            {
                AttributeSelectList            = new SelectList(_attributeService.GetAllAttributes(), "Id", "Name"),
                AttributeyMultiSelectList      = new MultiSelectList(_attributeService.GetAllAttributes(), "Id", "Name"),
                AttributeValuesMultiSelectList = new MultiSelectList((from av in _attributeService.GetAllAttributeValues()
                                                                      select new
                {
                    av.Id,
                    AttributeInCategory = _attributeService.FindAttributeById(av.AttributeId).Name + "/" + av.Name
                }),
                                                                     "Id",
                                                                     "AttributeInCategory"
                                                                     ),
                ProductMultiSelectList = new MultiSelectList(await _productService.GetAllProducts(), "Id", "Name"),
                LinksMultiList         = new MultiSelectList((from pav in _attributeService.GetAllProductAttributeValues()
                                                              select new
                {
                    pav.Id,
                    Association = _attributeService.FindAttributeValueById(pav.AttributeValueId).Name + " -> " +
                                  _productService.FindProductById(pav.ProductId).Name
                }),
                                                             "Id",
                                                             "Association"
                                                             )
            };

            return(View(mavm));
        }