public static CategoryItemModel Convert(
            this Category category,
            bool withDescription = false,
            bool withSEO         = false,
            bool withParner      = false
            )
        {
            var _return = new CategoryItemModel()
            {
                Id           = category.Id,
                Name         = category.Name,
                URL          = category.URL,
                CustomLayout = category.CustomLayout
            };

            if (withDescription)
            {
                _return.Description = category.Description;
            }
            if (withSEO)
            {
                _return.SeoTitle       = category.SeoTitle;
                _return.SeoKeyword     = category.SeoKeyword;
                _return.SeoDescription = category.SeoDescription;
            }
            if (withParner)
            {
                if (category.ParentCategory != null)
                {
                    _return.ParnerCategory = Convert(category.ParentCategory);
                }
            }
            return(_return);
        }
        public JsonResult Edit2(string id, CategoryItemModel model)
        {
            var bll = new EvaluateBLL();

            var success = true;
            var message = "保存成功";

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    bll.AddItem(new EvaluateCategoryItemEntity()
                    {
                        CategoryId = model.Category.CategoryId, ItemContent = model.ItemContent, ItemStandard = model.ItemStandard, Score = model.Score, EvaluateDept = model.EvaluateDept, UseDept = model.UseDept, UseDeptId = model.UseDeptId
                    });
                }
                else
                {
                    bll.EditItem(new EvaluateCategoryItemEntity()
                    {
                        ItemId = model.ItemId, CategoryId = model.Category.CategoryId, ItemContent = model.ItemContent, ItemStandard = model.ItemStandard, Score = model.Score, EvaluateDept = model.EvaluateDept, UseDept = model.UseDept, UseDeptId = model.UseDeptId
                    });
                }
            }
            catch (Exception ex)
            {
                success = false;
                message = ex.Message;
            }

            return(Json(new AjaxResult {
                type = success ? ResultType.success : ResultType.error, message = HttpUtility.JavaScriptStringEncode(message)
            }));
        }
Example #3
0
        public MainViewModel()
        {
            LoadCategories();
            LoadCategoryItemModels();

            _newCategoryItemModel       = new CategoryItemModel();
            _addNewCategoryItem         = new RelayCommand(AddCategoryItem);
            _removeSelectedCategoryItem = new RelayCommand(RemoveCategoryItem);
        }
        public void OnSubCategorySelected(CategoryItemModel subCategory)
        {
            if (_categoriesModel.SelectedSubCategory != null)
            {
                _subCategoriesNavigationStack.Push(_categoriesModel.SelectedSubCategory);
            }

            _categoriesModel.SetSelectedSubCategory(subCategory);
        }
Example #5
0
        // The Bind is for the DropDownList, the same is for the ViewBag as a new SelectList
        public ActionResult Create([Bind(Include = "CategoryItemModelId, HeaderName, CategoryModelId")] CategoryItemModel cItem)
        {
            if (ModelState.IsValid)
            {
                repository.InsertOrUpdate(cItem);
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryModelId = new SelectList(listRepository.GetAll(), "CategoryModelId", "CategoryName");
            return(View());
        }
Example #6
0
        private async void LoadCategoryItemModels()
        {
            StorageFile file = null;

            try
            {
                file = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("categoryitems.xml");
            }
            catch (Exception)
            {
            }

            if (file == null)
            {
                StorageFolder installationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
                string        xmlfile            = @"Assets\xml\CategoryItems.xml";
                file = await installationFolder.GetFileAsync(xmlfile);
            }

            Stream categoryItemStream = await file.OpenStreamForReadAsync();

            XDocument categoryItemDocument = XDocument.Load(categoryItemStream);

            IEnumerable <XElement> categoryItemList = categoryItemDocument.Descendants("categoryitem");

            CategoryItems = new ObservableCollection <CategoryItemModel>();

            foreach (XElement xElement in categoryItemList)
            {
                CategoryItemModel ci = new CategoryItemModel();
                ci.Name     = xElement.Element("name").Value;
                ci.Category = xElement.Element("category").Value;
                ci.Adress   = xElement.Element("adress").Value;
                ci.Email    = xElement.Element("email").Value;
                ci.ImageUrl = xElement.Element("imageurl").Value;
                ci.Phone    = xElement.Element("phone").Value;
                ci.Web      = xElement.Element("web").Value;

                CategoryItems.Add(new CategoryItemModel()
                {
                    Comments = new List <CommentModel>()
                });

                foreach (Categories categoriesModel in CategoriesModels)
                {
                    if (categoriesModel.Name.Equals(ci.Category))
                    {
                        categoriesModel.CategoryItems.Add(ci);
                    }
                }
            }
            OnPropertyChanged("CategoryItems");
        }
        public ActionResult CategoryItem(int?id)
        {
            TempData["shoppingURL"] = Request.Url.PathAndQuery;

            if (TempData["itemList"] != null)
            {
                //return Content("some some in temp data itemlist");
                TempData.Keep("itemList");
            }

            CategoryItemViewModel viewM = new CategoryItemViewModel();

            viewM.ProductList = new List <CategoryItemModel>();

            var queryProduct = (from o in db.Products
                                where o.ProductID > 1 && o.CategoryID == id
                                select o).ToList();

            foreach (Product item in queryProduct)
            {
                CategoryItemModel tempInstance = new CategoryItemModel();
                tempInstance.ImgLocation = item.ProductImageLocation;
                tempInstance.ProductID   = item.ProductID;
                tempInstance.ProductName = item.ProductName;
                tempInstance.UnitPrice   = item.ProductPrice;

                if (item.ProductDescription.Length > 12)
                {
                    tempInstance.ProductDescription = item.ProductDescription.Substring(0, 12) + "⋯";
                }
                else
                {
                    tempInstance.ProductDescription = item.ProductDescription;
                }


                tempInstance.QuantityInStock = (int)item.ProductQuantity;

                viewM.ProductList.Add(tempInstance);
            }


            return(View(viewM));
        }
Example #8
0
        //
        #region Category
        public static CategoryItemModel Convert(
            this Category category,
            bool withFullDesc = false,
            bool withParner   = false,
            bool withSEO      = false
            )
        {
            var _return = new CategoryItemModel()
            {
                ID            = category.ID,
                Name          = category.Name,
                UrlSlug       = category.UrlSlug,
                ParentID      = category.ParentID,
                ChildCategory = Convert(category.ChildCategory.ToList()),
                Quantity      = category.Quantity,
                DateCreated   = category.DateCreated,
                DateModified  = category.DateModified,
                OrderDisplay  = category.OrderDisplay,
                IsShow        = category.IsShow,
                IsDelete      = category.IsDelete,
                IsPublic      = category.IsPublic
            };

            if (withFullDesc)
            {
                _return.Description = category.Description;
            }
            if (withSEO)
            {
                _return.SEOTitle       = category.SEOTitle;
                _return.SEOKeyword     = category.SEOKeyword;
                _return.SEODescription = category.SEODescription;
            }
            if (withParner)
            {
                if (category.ParentCategory != null)
                {
                    _return.ParentCategory = Convert(category.ParentCategory);
                }
            }
            return(_return);
        }
        /// <summary>
        /// 编辑考评内容
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit2(string id)
        {
            CategoryItemModel model = null;

            if (!string.IsNullOrEmpty(id))
            {
                var bll  = new EvaluateBLL();
                var data = bll.GetCategoryItem(id);
                model = new CategoryItemModel()
                {
                    Category = new CategoryModel()
                    {
                        CategoryId = data.Category.CategoryId, Category = data.Category.Category
                    }, ItemId = data.ItemId, ItemContent = data.ItemContent, ItemStandard = data.ItemStandard, Score = data.Score, EvaluateDept = data.EvaluateDept, UseDept = data.UseDept
                };
            }
            else
            {
                model = new CategoryItemModel();
            }

            return(View(model));
        }
 private void OnCategorySelected(CategoryItemModel item)
 {
     _categoriesManager.OnCategorySelected(item);
 }
 private void CategorySelectedImpl(CategoryItemModel previousSelectedCategory, CategoryItemModel newSelectedCategory)
 {
     previousSelectedCategory?.RemoveState(ListItemState.Selected);
     newSelectedCategory.AddState(ListItemState.Selected);
 }
 public void OnCategorySelected(CategoryItemModel category)
 {
     CategorySelectedImpl(_categoriesModel.SelectedCategory, category);
     _categoriesModel.SetSelectedSubCategory(null, false);
     _categoriesModel.SetSelectedCategory(category);
 }