コード例 #1
0
        public IActionResult EditStoreCategory(int storeId, int categoryId, string storeName)
        {
            var storeCategoryModel = new EditCategoryStoreModel();
            var storeCategory      = _localService.GetStoreCategory(storeId, categoryId);

            storeCategoryModel.IsStoreCategoryExist = storeCategory != null;
            var options = _localService.GetAllOptions();

            if (storeCategory != null && options.Any())
            {
                var model = new CategoryOptionListModel();
                model.SelectedStoreName = storeName;
                var categoryOptionFromStore  = _n11Service.GetCategoryOptions(long.Parse(storeCategory.matched_category_code));
                var categoryOptionsFromLocal = _localService.GetStoreCategory(storeCategory.store_category_id)?.CategoryOptions;
                //if(categoryOptionFromStore != null && categoryOptionFromStore.Any())
                //{
                //    var matchedCategoryOptions = new List<MatchedCategoryOptionModel>();
                //    foreach(var fromStore in categoryOptionFromStore.OrderByDescending(c => c.IsRequired))
                //    {
                //        var fromLocal = categoryOptionsFromLocal?.FirstOrDefault(co => co.category_option_id == fromStore.Id);
                //        matchedCategoryOptions.Add(
                //            new MatchedCategoryOptionModel
                //            {
                //                FromStore = fromStore,
                //                FromLocal = fromLocal,
                //                IsSetted = fromLocal != null
                //            });
                //    }
                //    model.CategoryOptions = matchedCategoryOptions;
                //    model.Options = _localService.GetAllOptions();
                //    storeCategoryModel.OptionsModel = model;
                //}
            }
            storeCategoryModel.StoreCategory = storeCategory ?? new StoreCategory {
                category_id = categoryId, store_id = storeId
            };

            storeCategoryModel.SelectedStoreName = storeName;
            return(PartialView("_EditStoreCategory", storeCategoryModel));
        }