public InteCategoriesModels GetDetail(string id, int type = 0) { string Type = type.ToString(); try { InteCategoriesModels model = _factory.GetListCategory(null, id, null, CurrentUser.ListOrganizationId).FirstOrDefault(); if (model != null) { model.ImageURL = string.IsNullOrEmpty(model.ImageURL) ? Commons.Image100_100 : model.ImageURL; model.ProductTypeName = _productTypeFactory.GetProductTypeName(model.Type); if (model.ListCategoryOnStore != null && model.ListCategoryOnStore.Any()) { model.ListCategoryOnStore = model.ListCategoryOnStore.OrderBy(oo => oo.StoreName).ToList(); } if (!string.IsNullOrEmpty(model.ParentID) || model.ProductTypeName.ToLower().Equals("dish")) { List <string> LstStore = new List <string>(); LstStore.AddRange(model.ListCategoryOnStore.Select(s => s.StoreID).ToList()); model.ListCategories = GetSelectListParentCategory(LstStore, Type); // Updated 09222017 // No include list cate child of current cate model.lstCateGroup = GetSelectListParentCategorySortForEditCate(LstStore, Type, id, model.ParentID); } model.StoreName = string.Join(", ", model.ListCategoryOnStore.Select(z => z.StoreName).ToList()); foreach (var item in model.ListCategoryOnStore) { SelectListItem newItem = new SelectListItem(); newItem.Value = item.StoreID; newItem.Text = item.StoreName; newItem.Selected = true; model.ListStore.Add(newItem); } return(model); } else { model = new InteCategoriesModels(); return(model); } } catch (Exception ex) { _logger.Error("Categories_Detail: " + ex); return(null); } }
public List <SelectListItem> GetSelectListCategoriesInte(string StoreID, string itemType) { List <string> lstStore = new List <string>(); lstStore.Add(StoreID); List <InteCategoriesModels> lstData = _categoryFactoryInte.GetListCategory(lstStore, null, itemType, CurrentUser.ListOrganizationId); List <SelectListItem> slcCate = new List <SelectListItem>(); if (lstData != null) { foreach (InteCategoriesModels cate in lstData) { if (cate.ListChild != null) { foreach (var item in cate.ListChild) { slcCate.Add(new SelectListItem { Text = item.Name,// + " [" + item.StoreName + "]", Value = item.ID }); } } else { slcCate.Add(new SelectListItem { Text = cate.Name,// + " [" + cate.StoreName + "]", Value = cate.ID }); } } } return(slcCate); }