public ActionResult SaveChanges(CategoryModel model) { if (!ModelState.IsValid) return null; T_Category entity = CategoryModel.ModelToEntity(model); // Save add action if (model.cat_id <= 0) { _context.Add(entity); _context.SaveChanges(); Log.Info(string.Format("Edit category id={0} name={1}", entity.cat_id, entity.cat_name)); return GenerateJson(entity, true, "Nouvelle catégorie ajoutée."); } // Save edit action else { _context.Edit(entity); _context.SaveChanges(); Log.Info(string.Format("Create category id={0} name={1}", entity.cat_id, entity.cat_name)); return GenerateJson(entity, false, "Catégorie modifiée."); } }
public ActionResult Delete([DataSourceRequest]DataSourceRequest request, CategoryModel model) { this.Data.Categories.Delete(model.Id); this.Data.SaveChanges(); return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public JsonResult Delete(CategoryModel model) { if (ModelState.IsValid) return Json(_service.Delete(model)); return Json(null); }
public async Task<IHttpActionResult> AddCategory(CategoryModel model) { try { var category = new DrNajeeb.EF.Category(); category.Name = model.Name; category.IsShowOnFrontPage = model.IsShowOnFrontPage ?? false; category.SEOName = Helpers.URLHelpers.URLFriendly(model.Name); category.CreatedOn = DateTime.UtcNow; category.Active = true; var maxValue = await _Uow._Categories.GetAll(x => x.Active == true).OrderByDescending(x => x.DisplayOrder).FirstOrDefaultAsync(); category.DisplayOrder = (maxValue != null) ? maxValue.DisplayOrder + 1 : 1; //todo : add useid in createdby //todo : set seo name like QA site //todo : set and save category url //set display order of categories _Uow._Categories.Add(category); await _Uow.CommitAsync(); return Ok(); } catch (Exception ex) { return InternalServerError(ex); } }
protected void btnSubmit_Click(object sender, EventArgs e) { CategoryModel model = new CategoryModel(); Category c = CreateCategory(); lblResult.Text = model.InsertCategory(c); Response.Redirect("~/Pages/Management/ManageWebsite.aspx", false); }
public Category CreateNewEntity(CategoryModel categoryModel) { Contract.Requires<ArgumentNullException>(categoryModel != null); Contract.Requires<ArgumentException>(categoryModel.Id == Guid.Empty, "Category should not have an id already."); Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(categoryModel.Name), "Category requires a name."); Contract.Ensures(Contract.Result<Category>() != null); throw new NotImplementedException(); }
public void Should_not_have_error_when_pageSizeOptions_is_null_or_empty() { var model = new CategoryModel(); model.PageSizeOptions = null; _validator.ShouldNotHaveValidationErrorFor(x => x.PageSizeOptions, model); model.PageSizeOptions = ""; _validator.ShouldNotHaveValidationErrorFor(x => x.PageSizeOptions, model); }
public static CategoryModel ToCategoryModel(this Category global) { CategoryModel category = new CategoryModel { Id = global.Id, Name = global.Name }; return category; }
public ActionResult Edit(CategoryModel model) { if (model.Id == 0) ModelState.Remove("Id"); if (ModelState.IsValid) return Json(model.Id == default(int) ? _service.Add(model) : _service.Edit(model)); return PartialView("EditorTemplates/_Edit", model); }
public CategoryViewModel( CategoryModel categoryModel, string pageTitle, INavigationServiceFacade navigationServiceFacade, bool synchronizedWithSelection) { this._category = categoryModel; this._pageTitle = pageTitle; this._navigationServiceFacade = navigationServiceFacade; }
public static ProductModel CreateProduct(string brand, int width, int height, string type, CategoryModel category) { return new ProductModel() { Brand = brand, Width = width, Height = height, Type = type, ProductCategory = category }; }
public CategoryModel GetByName(string name) { var categoryEntity = context.CategoryEntities.FirstOrDefault(m => m.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (categoryEntity == null) return null; var category = new CategoryModel() { Id = categoryEntity.Id, Name = categoryEntity.Name }; return category; }
public ActionResult Create([DataSourceRequest]DataSourceRequest request, CategoryModel model) { if (model != null && this.ModelState.IsValid) { var category = Mapper.Map<Category>(model); this.Data.Categories.Add(category); this.Data.SaveChanges(); model.Id = category.Id; } return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Edit(int id, CategoryModel model) { var context = new ApplicationDbContext(); var category = context.Categories.Single(x => x.CategoryId == id); //.FirstOrDefault(c => c.CategoryId == id); TryUpdateModel(category); return RedirectToAction("Index"); // // category.Title = model.Title; //context.SaveChanges(); }
protected override void Because_of() { var categoryModel = new CategoryModel(); categoryModel.Category = categoryModel; var userModel = new UserModel(); var userGroupModel = new UserGroupModel(); userModel.Category = categoryModel; userModel.Group = userGroupModel; userGroupModel.Users.Add(userModel); _destination = Mapper.Map<UserDto>(userModel); }
public Category getCategory(CategoryModel model) { var cat = new Category(); if (model != null) { cat.CategoryDescription = model.CategoryDescription; cat.CategoryId = model.CategoryId; cat.CategoryName = model.CategoryName; cat.CategoryPicture = model.CategoryPicture; cat.Products = getProduct(model.Products); } return cat; }
// Constructeur de copie public BookViewModel(BookViewModel bvm) { this._authors = bvm._authors; this._authorService = bvm._authorService; this._book = bvm.Book; this._categories = bvm._categories; this._categoryService = bvm._categoryService; this._isNewPhoto = bvm._isNewPhoto; this._navigationServiceFacade = bvm._navigationServiceFacade; this._pageTitle = bvm._pageTitle; this._rates = bvm._rates; this._selectedAuthor = bvm._selectedAuthor; this._selectedCategory = bvm._selectedCategory; this._state = bvm._state; this._windowServices = bvm._windowServices; }
public ActionResult Update([DataSourceRequest]DataSourceRequest request, CategoryModel model) { if (model != null && this.ModelState.IsValid) { var category = this.Data.Categories.All().FirstOrDefault(x => x.Id == model.Id); if (category != null) { category.Name = model.Name; } this.Data.Categories.Update(category); this.Data.SaveChanges(); } return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
/// <summary> /// 获取论坛板块信息 CategoryModel /// </summary> public BbsBoardModel GetBbsBoard(CategoryModel c) { cms_varticle lastpost = new cms_varticle(); BbsBoardModel board = new BbsBoardModel(); if (c != null) { board = GetBbsBoardStat(Utils.StrToInt(c.CateId)); board.CateId = c.CateId; board.Path = c.Path; board.CateName = c.CateName; board.ReName = c.ReName; board.SubCount = c.SubCount; board.ReplyPermit = c.ReplyPermit; board.ParentId = c.ParentId; } return board; }
async void MainCategories_Loaded(object sender, RoutedEventArgs e) { if (AppData.CheckNetworkConnection()) { this.ViewModel.ShowOverlay(); string categoriesResponse = await webServiceHandler.GetResponseThroughGet(AppData.AllCategoriesUrl, false); categories = JsonConvert.DeserializeObject<CategoryModel>(categoriesResponse); this.Background = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255)); this.ViewModel.HideOverlay(); this.ViewModel.Categories = categories; } else { MessageDialog msg = new MessageDialog(AppData.NoInternetMessage); await msg.ShowAsync(); } }
public List<CategoryModel> AllCategories() { using (var db = new TankshopDbContext()) { var dbCategories = db.Categories.ToList(); var categoryModels = new List<CategoryModel>(); foreach (var c in dbCategories) { var categoryModel = new CategoryModel() { CategoryId = c.CategoryId, CategoryName = c.Name, Products = GetProductsByCategory(c.CategoryId) }; categoryModels.Add(categoryModel); } return categoryModels; } }
public ActionResult AddCategory(CategoryModel categoryModel) { if (ModelState.IsValid) { using (ClothesShopEntities entity = new ClothesShopEntities()) { if (entity.Categories.Where(category => category.CategoryName == categoryModel.Name).Count() == 0) { Category newCategory = new Category() { CategoryName = categoryModel.Name }; entity.AddToCategories(newCategory); entity.SaveChanges(); } else { ModelState.AddModelError("", "A category with the same name already exists."); } } } return RedirectToAction("Categories"); }
protected void _initModel() { Productions.Properties.Settings setting = new Productions.Properties.Settings(); CategoryParser newParser = new CategoryParser(); dataModel = new CategoryModel( this.gvCategories, setting.DB_HOST, setting.DB_PORT, setting.DB_NAME, setting.DB_USER, setting.DB_PASS, "Production.Categories", newParser); //dataModel = new CategoryModel(this.gvCategories, ".\\SQL2008", setting.DB_PORT, setting.DB_NAME, setting.DB_USER, setting.DB_PASS, "Production.Categories", newParser); newParser.DataModel = dataModel; dataModel.resetControl(); }
public List<CategoryModel> getCategory(IEnumerable<Category> list) { var modelList = new List<CategoryModel>(); if(list.Count() > 0) { foreach (var model in list) { var cat = new CategoryModel(); if (model != null) { cat.CategoryDescription = model.CategoryDescription; cat.CategoryId = model.CategoryId; cat.CategoryName = model.CategoryName; cat.CategoryPicture = model.CategoryPicture; cat.Products = getProduct(model.Products); } modelList.Add(cat); } } return modelList; }
public async Task <APIResult <SaveResponse> > Insert([FromBody] CategoryModel model) => await _service.InsertAsync(model);
protected void UpdateLocales(Category category, CategoryModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(category, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.Description, localized.Description, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); //search engine name var seName = category.ValidateSeName(localized.SeName, localized.Name, false); _urlRecordService.SaveSlug(category, seName, localized.LanguageId); } }
public ActionResult Category(string id,string sort="default",string order="asc",int pageIndex=0,int pageSize=2) { var products = _unitOfWork.ProductRepository.Get().ToList();//new ProductsBuilder().Build()); @ViewBag.Sort = sort; @ViewBag.Order = order; @ViewBag.PageSize = pageSize; var category = _categories.First(i => i.Id==new Guid(id)); var allCategories = category.GetAllCategories(); var selectedProducts = products.Where(p => allCategories.Contains(p.CategoryId)).ToList(); var paginatedProducts = new PaginatedList<Product>(selectedProducts, pageIndex, pageSize); var categoryViewModels = GetCategoriesByCategory(category, products); var specialProduct = products.First(i => i.Id == new Guid("CD4879A0-C210-4DAA-A6DE-A59E9CC153BF")); var specialProductViewModel = new SpecialProductViewModel { Id = specialProduct.Id.ToString(), Name = specialProduct.Name, OldPrice = specialProduct.OldPrice.HasValue? specialProduct.OldPrice.Value.ToString("C"):string.Empty, NewPrice = specialProduct.NewPrice.ToString("C"), RatingImagePath = specialProduct.RatingImagePath, Image240x192Path = specialProduct.Image240x192Path }; var refineSearchs = new List<RefineSearch>(); foreach (var childCategory in _categories.Where(c=>c.ParentCategory==category)) { var refineSearch = new RefineSearch { Id = childCategory.Id.ToString(), Name = childCategory.Name, Total = products.Count(p => p.CategoryId == childCategory.Id) }; refineSearchs.Add(refineSearch); } var productsBlock = GetProductsBlocks(paginatedProducts.ToList()); var categoryModel = new CategoryModel { Id=id, Name=category.Name, Description = category.Description, ImagePath=category.ImagePath, RefineSearches=refineSearchs, CategoryViewModels=categoryViewModels, SpecialProductViewModel=specialProductViewModel, ProductsBlock=productsBlock, PaginatedList=paginatedProducts }; return View(categoryModel); }
/// <summary> /// 分类 /// </summary> public ActionResult Category() { //分类id int cateId = GetRouteInt("cateId"); if (cateId == 0) { cateId = WebHelper.GetQueryInt("cateId"); } //品牌id int brandId = GetRouteInt("brandId"); if (brandId == 0) { brandId = WebHelper.GetQueryInt("brandId"); } //筛选价格 int filterPrice = GetRouteInt("filterPrice"); if (filterPrice == 0) { filterPrice = WebHelper.GetQueryInt("filterPrice"); } //筛选属性 string filterAttr = GetRouteString("filterAttr"); if (filterAttr.Length == 0) { filterAttr = WebHelper.GetQueryString("filterAttr"); } //是否只显示有货 int onlyStock = GetRouteInt("onlyStock"); if (onlyStock == 0) { onlyStock = WebHelper.GetQueryInt("onlyStock"); } //排序列 int sortColumn = GetRouteInt("sortColumn"); if (sortColumn == 0) { sortColumn = WebHelper.GetQueryInt("sortColumn"); } //排序方向 int sortDirection = GetRouteInt("sortDirection"); if (sortDirection == 0) { sortDirection = WebHelper.GetQueryInt("sortDirection"); } //当前页数 int page = GetRouteInt("page"); if (page == 0) { page = WebHelper.GetQueryInt("page"); } //分类信息 CategoryInfo categoryInfo = Categories.GetCategoryById(cateId); if (categoryInfo == null) { return(PromptView("/", "此分类不存在")); } //分类关联品牌列表 List <BrandInfo> brandList = Categories.GetCategoryBrandList(cateId); //分类筛选属性及其值列表 List <KeyValuePair <AttributeInfo, List <AttributeValueInfo> > > cateAAndVList = Categories.GetCategoryFilterAAndVList(cateId); //分类价格范围列表 string[] catePriceRangeList = StringHelper.SplitString(categoryInfo.PriceRange, "\r\n"); //筛选属性处理 List <int> attrValueIdList = new List <int>(); string[] filterAttrValueIdList = StringHelper.SplitString(filterAttr, "-"); if (filterAttrValueIdList.Length != cateAAndVList.Count)//当筛选属性和分类的筛选属性数目不对应时,重置筛选属性 { if (cateAAndVList.Count == 0) { filterAttr = "0"; } else { int count = cateAAndVList.Count; StringBuilder sb = new StringBuilder(); for (int i = 0; i < count; i++) { sb.Append("0-"); } filterAttr = sb.Remove(sb.Length - 1, 1).ToString(); } } else { foreach (string attrValueId in filterAttrValueIdList) { int temp = TypeHelper.StringToInt(attrValueId); if (temp > 0) { attrValueIdList.Add(temp); } } } //分页对象 PageModel pageModel = new PageModel(20, page, Products.GetCategoryProductCount(cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock)); //视图对象 CategoryModel model = new CategoryModel() { CateId = cateId, BrandId = brandId, FilterPrice = filterPrice, FilterAttr = filterAttr, OnlyStock = onlyStock, SortColumn = sortColumn, SortDirection = sortDirection, CategoryInfo = categoryInfo, BrandList = brandList, CatePriceRangeList = catePriceRangeList, AAndVList = cateAAndVList, PageModel = pageModel, ProductList = Products.GetCategoryProductList(pageModel.PageSize, pageModel.PageNumber, cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock, sortColumn, sortDirection) }; return(View(model)); }
public ActionResult ProductAddPopupList(DataSourceRequest command, CategoryModel.AddCategoryProductModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) return AccessDeniedView(); var gridModel = new DataSourceResult(); var products = _productService.SearchProducts( categoryIds: new List<int>() { model.SearchCategoryId }, manufacturerId: model.SearchManufacturerId, storeId: model.SearchStoreId, vendorId: model.SearchVendorId, productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null, keywords: model.SearchProductName, pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true ); gridModel.Data = products.Select(x => x.ToModel()); gridModel.Total = products.TotalCount; return Json(gridModel); }
public async Task <IResponse> UpdateAsync(CategoryModel model) { return(await _dal.UpdateAsync(_mapper.Map <Category>(model))); }
public CategoryModel getCategoryList(CategoryViewModel foRequest) { if (foRequest.inPageSize <= 0) { foRequest.inPageSize = 10; } if (foRequest.inPageIndex <= 0) { foRequest.inPageIndex = 1; } if (foRequest.stSortColumn == "") { foRequest.stSortColumn = null; } if (foRequest.stSearch == "") { foRequest.stSearch = null; } Func <IQueryable <Categories>, IOrderedQueryable <Categories> > orderingFunc = query => query.OrderBy(x => x.Id); Expression <Func <Categories, bool> > expression = null; if (!string.IsNullOrEmpty(foRequest.stSearch)) { foRequest.stSearch = foRequest.stSearch.Replace("%20", " "); expression = x => x.Name.ToLower().Contains(foRequest.stSearch.ToLower()) && x.IsDeleted == false; } else { expression = x => x.IsDeleted == false; } if (!string.IsNullOrEmpty(foRequest.stSortColumn)) { switch (foRequest.stSortColumn) { case "ID DESC": orderingFunc = q => q.OrderByDescending(s => s.Id); break; case "ID ASC": orderingFunc = q => q.OrderBy(s => s.Id); break; case "Name DESC": orderingFunc = q => q.OrderByDescending(s => s.Name); break; case "Name ASC": orderingFunc = q => q.OrderBy(s => s.Name); break; case "GST DESC": orderingFunc = q => q.OrderByDescending(s => s.GST); break; case "GST ASC": orderingFunc = q => q.OrderBy(s => s.GST); break; case "Description DESC": orderingFunc = q => q.OrderByDescending(s => s.Description); break; case "Description ASC": orderingFunc = q => q.OrderBy(s => s.Description); break; } } (List <Categories>, int)objUsers = Repository <Categories> .GetEntityListForQuery(expression, orderingFunc, null, foRequest.inPageIndex, foRequest.inPageSize); CategoryModel objCategoryViewModel = new CategoryModel(); objCategoryViewModel.inRecordCount = objUsers.Item2; objCategoryViewModel.inPageIndex = foRequest.inPageIndex; objCategoryViewModel.Pager = new Pager(objUsers.Item2, foRequest.inPageIndex); if (objUsers.Item1.Count > 0) { foreach (var catg in objUsers.Item1) { objCategoryViewModel.loCategoryList.Add(new CategoryViewModel { Id = catg.Id, Name = catg.Name, Description = catg.Description, IsActive = catg.IsActive, GST = catg.GST }); } } return(objCategoryViewModel); }
public static Category ToEntity(this CategoryModel model) { return(Mapper.Map <CategoryModel, Category>(model)); }
public static Category ToEntity(this CategoryModel model, Category destination) { return(Mapper.Map(model, destination)); }
/// <summary> /// 执行操作的方法 /// </summary> private void Action() { string cmd = Request["cmd"]; if (String.IsNullOrEmpty(cmd)) { return; } string ids = Request.QueryString["ids"]; if (cmd == "moveup") { bll_category.MoveUp(ids); } else if (cmd == "movedown") { bll_category.MoveDown(ids); } else if (cmd == "onoff") { bll_category.UpdateStatus(ids, "onoff"); } else if (cmd == "enab") { bll_category.UpdateStatus(ids, "enab"); } else if (cmd == "del") { bll_category.Delete(ids); } else if (cmd == "updateall") { foreach (string key in Request.Form.AllKeys) { if (key.StartsWith("title")) { string title = Request.Form[key]; if (String.IsNullOrEmpty(title)) { continue; } if (key.IndexOf("#") > 0) { string fid = Request.Form[key.Replace("title", "fid")]; if (!StringHelper.IsNumber(fid)) { continue; } CategoryModel category = new CategoryModel(); category.Title = title; category.FatherId = Convert.ToInt32(fid); bll_category.Insert(category); } else { string id = key.Replace("title", ""); CategoryModel category = bll_category.GetModel(id); if (category == null) { continue; } category.Title = title; bll_category.Update(category); } } } WebUtility.ShowAlertMessage("全部保存成功!", Request.RawUrl); } Response.Redirect(Request.Url.AbsolutePath + WebUtility.GetUrlParams("?", true)); }
public JsonNetResult UpdateCategoryEdit(int deviceId, CategoryModel category) { ConnectCmsRepository.CategoryRepository.UpdateCategory(deviceId, category); return(JsonNet(true)); }
/// <summary> /// Insert or Update Category /// </summary> /// <param name="objCategoryModel">object of Category Model</param> /// <param name="ErrorCode"></param> /// <param name="ErrorMessage"></param> /// <returns></returns> public CategoryModel InsertUpdateCategory(CategoryModel objCategoryModel) { //call InsertUpdateCategory Method of dataLayer and return CategoryModel return(objDLCategory.InsertUpdateCategory(objCategoryModel)); }
public SingleCategoryModel(CategoryModel model) { Title = model.CategoryName; }
public ActionResult SaveData() { var model = new CategoryModel(); return(PartialView(model)); }
public BookViewModel( BookModel bookModel, string pageTitle, INavigationServiceFacade navigationServiceFacade, bool synchronizedWithSelection) { this._book = bookModel; this._pageTitle = pageTitle; this._navigationServiceFacade = navigationServiceFacade; if (_categoryService != null) this._categories = new ObservableCollection<CategoryModel>(this._categoryService.GetByCriteria(CategoryCriteria.Empty)); if (_authorService != null) this._authors = new ObservableCollection<AuthorModel>(this._authorService.GetByCriteria(AuthorCriteria.Empty)); #region Initialisation supplémentaire pour problème dans le ListPicker IEnumerator enumcat = this._categories.GetEnumerator(); enumcat.MoveNext(); _selectedCategory = enumcat.Current as CategoryModel; IEnumerator enumaut = this._authors.GetEnumerator(); enumaut.MoveNext(); _selectedAuthor = enumaut.Current as AuthorModel; #endregion // Initialisation supplémentaire pour problème dans le ListPicker }
public ActionResult Create(CategoryModel model, bool continueEditing, FormCollection form) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var category = model.ToEntity(); category.CreatedOnUtc = DateTime.UtcNow; category.UpdatedOnUtc = DateTime.UtcNow; MediaHelper.UpdatePictureTransientStateFor(category, c => c.PictureId); _categoryService.InsertCategory(category); //search engine name model.SeName = category.ValidateSeName(model.SeName, category.Name, true); _urlRecordService.SaveSlug(category, model.SeName, 0); //locales UpdateLocales(category, model); //disounts var allDiscounts = _discountService.GetAllDiscounts(DiscountType.AssignedToCategories, null, true); foreach (var discount in allDiscounts) { if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id)) { category.AppliedDiscounts.Add(discount); } } _categoryService.UpdateCategory(category); //update "HasDiscountsApplied" property _categoryService.UpdateHasDiscountsApplied(category); //update picture seo file name UpdatePictureSeoNames(category); //ACL (customer roles) SaveCategoryAcl(category, model); //Stores _storeMappingService.SaveStoreMappings <Category>(category, model.SelectedStoreIds); _eventPublisher.Publish(new ModelBoundEvent(model, category, form)); //activity log _customerActivityService.InsertActivity("AddNewCategory", _localizationService.GetResource("ActivityLog.AddNewCategory"), category.Name); NotifySuccess(_localizationService.GetResource("Admin.Catalog.Categories.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = category.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form //templates PrepareTemplatesModel(model); //parent categories if (model.ParentCategoryId.HasValue) { var parentCategory = _categoryService.GetCategoryById(model.ParentCategoryId.Value); if (parentCategory != null && !parentCategory.Deleted) { model.ParentCategoryBreadcrumb = parentCategory.GetCategoryBreadCrumb(_categoryService); } else { model.ParentCategoryId = 0; } } PrepareCategoryModel(model, null, true); //ACL PrepareAclModel(model, null, true); //Stores PrepareStoresMappingModel(model, null, true); return(View(model)); }
public CategoryModel AddNewCategory(CategoryModel category) { categories.Add(category); return(category); }
private void LoadCategory() { categoryLogic = new CategoryModel(); rpCategory.DataSource = categoryLogic.GetCategoryList(); rpCategory.DataBind(); }
public void Create(CategoryModel category) { category.ID = Guid.NewGuid(); Context.Categories.Add(category); Context.SaveChanges(); }
public int CategoryCount(int CategoryID) { categoryLogic = new CategoryModel(); return(categoryLogic.CountDocumentInCategory(CategoryID)); }
public ActionResult searchCategory(CategoryViewModel foSearchRequest) { CategoryModel loCategoryModel = getCategoryList(foSearchRequest); return(PartialView("~/Areas/Admin/Views/Category/_Category.cshtml", loCategoryModel)); }
public string M_Category_Select([FromBody] CategoryModel Cmodel) { Category_BL Cbl = new Category_BL(); return(Cbl.M_Category_Select(Cmodel)); }
public ActionResult ProductUpdate(CategoryModel.CategoryProductModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) return AccessDeniedView(); var productCategory = _categoryService.GetProductCategoryById(model.Id); if (productCategory == null) throw new ArgumentException("No product category mapping found with the specified id"); productCategory.IsFeaturedProduct = model.IsFeaturedProduct; productCategory.DisplayOrder = model.DisplayOrder1; _categoryService.UpdateProductCategory(productCategory); return new NullJsonResult(); }
public string Category_CUD([FromBody] CategoryModel bmodel) { Category_BL Cbl = new Category_BL(); return(Cbl.Category_CUD(bmodel)); }
public ActionResult ProductAddPopup(string btnId, string formId, CategoryModel.AddCategoryProductModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) return AccessDeniedView(); if (model.SelectedProductIds != null) { foreach (int id in model.SelectedProductIds) { var product = _productService.GetProductById(id); if (product != null) { var existingProductCategories = _categoryService.GetProductCategoriesByCategoryId(model.CategoryId, 0, int.MaxValue, true); if (existingProductCategories.FindProductCategory(id, model.CategoryId) == null) { _categoryService.InsertProductCategory( new ProductCategory() { CategoryId = model.CategoryId, ProductId = id, IsFeaturedProduct = false, DisplayOrder = 1 }); } } } } ViewBag.RefreshPage = true; ViewBag.btnId = btnId; ViewBag.formId = formId; return View(model); }
public string Get_CategoryType([FromBody] CategoryModel Cmodel) { Category_BL Cbl = new Category_BL(); return(Cbl.Get_CategoryType(Cmodel)); }
private Category MapCategoryModel(Category category, CategoryModel categoryModel) { category.EntityShortId = Convert.ToInt16(categoryModel.IdCategory.Value); category.UniqueId = categoryModel.UniqueId.Value; return(category); }
protected void PrepareCategoryModel(CategoryModel model, Category category, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } model.GridPageSize = _adminAreaSettings.GridPageSize; var discounts = _discountService.GetAllDiscounts(DiscountType.AssignedToCategories, null, true); model.AvailableDiscounts = discounts.ToList(); if (!excludeProperties) { model.SelectedDiscountIds = category.AppliedDiscounts.Select(d => d.Id).ToArray(); } if (category != null) { model.CreatedOn = _dateTimeHelper.ConvertToUserTime(category.CreatedOnUtc, DateTimeKind.Utc); model.UpdatedOn = _dateTimeHelper.ConvertToUserTime(category.UpdatedOnUtc, DateTimeKind.Utc); } model.AvailableDefaultViewModes.Add( new SelectListItem { Value = "grid", Text = _localizationService.GetResource("Common.Grid"), Selected = model.DefaultViewMode.IsCaseInsensitiveEqual("grid") } ); model.AvailableDefaultViewModes.Add( new SelectListItem { Value = "list", Text = _localizationService.GetResource("Common.List"), Selected = model.DefaultViewMode.IsCaseInsensitiveEqual("list") } ); // add available badges model.AvailableBadgeStyles.Add(new SelectListItem { Value = "0", Text = "Secondary", Selected = model.BadgeStyle == 0 }); model.AvailableBadgeStyles.Add(new SelectListItem { Value = "1", Text = "Primary", Selected = model.BadgeStyle == 1 }); model.AvailableBadgeStyles.Add(new SelectListItem { Value = "2", Text = "Success", Selected = model.BadgeStyle == 2 }); model.AvailableBadgeStyles.Add(new SelectListItem { Value = "3", Text = "Info", Selected = model.BadgeStyle == 3 }); model.AvailableBadgeStyles.Add(new SelectListItem { Value = "4", Text = "Warning", Selected = model.BadgeStyle == 4 }); model.AvailableBadgeStyles.Add(new SelectListItem { Value = "5", Text = "Danger", Selected = model.BadgeStyle == 5 }); model.AvailableBadgeStyles.Add(new SelectListItem { Value = "6", Text = "Light", Selected = model.BadgeStyle == 6 }); model.AvailableBadgeStyles.Add(new SelectListItem { Value = "7", Text = "Dark", Selected = model.BadgeStyle == 7 }); }
public ActionResult Edit(CategoryModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) { return(AccessDeniedView()); } var category = _categoryService.GetCategoryById(model.Id); if (category == null || category.Deleted) { //No category found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { int prevPictureId = category.PictureId; category = model.ToEntity(category); category.UpdatedOnUtc = DateTime.UtcNow; _categoryService.UpdateCategory(category); //search engine name model.SeName = category.ValidateSeName(model.SeName, category.Name, true); _urlRecordService.SaveSlug(category, model.SeName, 0); //locales UpdateLocales(category, model); //discounts var allDiscounts = _discountService.GetAllDiscounts(DiscountType.AssignedToCategories, null, true); foreach (var discount in allDiscounts) { if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id)) { //new role if (category.AppliedDiscounts.Count(d => d.Id == discount.Id) == 0) { category.AppliedDiscounts.Add(discount); } } else { //removed role if (category.AppliedDiscounts.Count(d => d.Id == discount.Id) > 0) { category.AppliedDiscounts.Remove(discount); } } } _categoryService.UpdateCategory(category); //update "HasDiscountsApplied" property _categoryService.UpdateHasDiscountsApplied(category); //delete an old picture (if deleted or updated) if (prevPictureId > 0 && prevPictureId != category.PictureId) { var prevPicture = _pictureService.GetPictureById(prevPictureId); if (prevPicture != null) { _pictureService.DeletePicture(prevPicture); } } //update picture seo file name UpdatePictureSeoNames(category); //ACL SaveCategoryAcl(category, model); //Stores SaveStoreMappings(category, model); //activity log _customerActivityService.InsertActivity("EditCategory", _localizationService.GetResource("ActivityLog.EditCategory"), category.Name); SuccessNotification(_localizationService.GetResource("Admin.Catalog.Categories.Updated")); if (continueEditing) { //selected tab SaveSelectedTabIndex(); return(RedirectToAction("Edit", category.Id)); } else { return(RedirectToAction("List")); } } //If we got this far, something failed, redisplay form //parent categories model.ParentCategories = new List <DropDownItem> { new DropDownItem { Text = "[None]", Value = "0" } }; if (model.ParentCategoryId > 0) { var parentCategory = _categoryService.GetCategoryById(model.ParentCategoryId); if (parentCategory != null && !parentCategory.Deleted) { model.ParentCategories.Add(new DropDownItem { Text = parentCategory.GetFormattedBreadCrumb(_categoryService), Value = parentCategory.Id.ToString() }); } else { model.ParentCategoryId = 0; } } //templates PrepareTemplatesModel(model); //discounts PrepareDiscountModel(model, category, true); //ACL PrepareAclModel(model, category, true); //Stores PrepareStoresMappingModel(model, category, true); return(View(model)); }
public ActionResult Edit(CategoryModel model, bool continueEditing, FormCollection form) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } var category = _categoryService.GetCategoryById(model.Id); if (category == null || category.Deleted) { return(RedirectToAction("Index")); } if (ModelState.IsValid) { category = model.ToEntity(category); category.ParentCategoryId = model.ParentCategoryId ?? 0; MediaHelper.UpdatePictureTransientStateFor(category, c => c.PictureId); _categoryService.UpdateCategory(category); //search engine name model.SeName = category.ValidateSeName(model.SeName, category.Name, true); _urlRecordService.SaveSlug(category, model.SeName, 0); //locales UpdateLocales(category, model); //discounts var allDiscounts = _discountService.GetAllDiscounts(DiscountType.AssignedToCategories, null, true); foreach (var discount in allDiscounts) { if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id)) { //new role if (category.AppliedDiscounts.Where(d => d.Id == discount.Id).Count() == 0) { category.AppliedDiscounts.Add(discount); } } else { //removed role if (category.AppliedDiscounts.Where(d => d.Id == discount.Id).Count() > 0) { category.AppliedDiscounts.Remove(discount); } } } _categoryService.UpdateCategory(category); // update "HasDiscountsApplied" property _categoryService.UpdateHasDiscountsApplied(category); // update picture seo file name UpdatePictureSeoNames(category); // ACL SaveAclMappings(category, model); // Stores SaveStoreMappings(category, model); _eventPublisher.Publish(new ModelBoundEvent(model, category, form)); //activity log _customerActivityService.InsertActivity("EditCategory", _localizationService.GetResource("ActivityLog.EditCategory"), category.Name); NotifySuccess(T("Admin.Catalog.Categories.Updated")); return(continueEditing ? RedirectToAction("Edit", category.Id) : RedirectToAction("Index")); } //If we got this far, something failed, redisplay form //parent categories if (model.ParentCategoryId.HasValue) { var parentCategory = _categoryService.GetCategoryTree(model.ParentCategoryId.Value, true); if (parentCategory != null) { model.ParentCategoryBreadcrumb = _categoryService.GetCategoryPath(parentCategory); } else { model.ParentCategoryId = 0; } } //templates PrepareTemplatesModel(model); PrepareCategoryModel(model, category, true); //ACL PrepareAclModel(model, category, true); //Stores PrepareStoresMappingModel(model, category, true); return(View(model)); }
public static Category ToEntity(this CategoryModel model, Category destination) { return(TypeAdapter.Adapt(model, destination)); }
public ActionResult Category(int categoryId, CatalogPagingFilteringModel command) { var category = _categoryService.GetCategoryById(categoryId); if (category == null || category.Deleted) { return(Content("")); } //Check whether the current user has a "Manage catalog" permission //It allows him to preview a category before publishing if (!category.Published && !_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) { return(Content("")); } //ACL (access control list) if (!_aclService.Authorize(category)) { return(Content("")); } //Store mapping if (!_storeMappingService.Authorize(category)) { return(Content("")); } if (command.PageSize == 0) { command.PageSize = 8; } if (command.PageNumber <= 0) { command.PageNumber = 1; } var model = new CategoryModel { Id = category.Id, Name = category.GetLocalized(x => x.Name), SeName = category.GetSeName(), Description = category.GetLocalized(x => x.Description) }; //subcategories model.SubCategories = _categoryService .GetAllCategoriesByParentCategoryId(categoryId) .Select(x => { var subCatName = x.GetLocalized(y => y.Name); var subCatModel = new CategoryModel { Id = x.Id, Name = subCatName, SeName = x.GetSeName(), }; //prepare picture model int pictureSize = 125; var picture = _pictureService.GetPictureById(x.PictureId); subCatModel.PictureModel = new PictureModel { FullSizeImageUrl = _pictureService.GetPictureUrl(picture), ImageUrl = _pictureService.GetPictureUrl(picture, pictureSize), Title = string.Format(_localizationService.GetResource("Media.Category.ImageLinkTitleFormat"), subCatName), AlternateText = string.Format(_localizationService.GetResource("Media.Category.ImageAlternateTextFormat"), subCatName) }; return(subCatModel); }) .ToList(); var categoryIds = new List <int>(); if (categoryId > 0) { categoryIds.Add(categoryId); } //products IList <int> filterableSpecificationAttributeOptionIds; var products = _productService.SearchProducts(out filterableSpecificationAttributeOptionIds, categoryIds: categoryIds, storeId: _storeContext.CurrentStore.Id, visibleIndividuallyOnly: true, featuredProducts: null, orderBy: ProductSortingEnum.Position, pageIndex: command.PageNumber - 1, pageSize: command.PageSize); model.Products = PrepareProductOverviewModels(products).ToList(); model.PagingFilteringContext.LoadPagedList(products); return(PartialView("~/Plugins/Misc.FacebookShop/Views/MiscFacebookShop/Category.cshtml", model)); }
public static Category ToEntity(this CategoryModel model) { return(TypeAdapter.Adapt <CategoryModel, Category>(model)); }
public void Update(CategoryModel category) { Context.Categories.Update(category); Context.SaveChanges(); }
/// <summary> /// 递归生成树的方法 /// </summary> public StringBuilder CreateTree(int fatherId) { StringBuilder strHtml = new StringBuilder(); List <CategoryModel> categoryList = bll_category.GetListByFatherId(fatherId); for (int i = 0; i < categoryList.Count; i++) { CategoryModel category = categoryList[i]; string nodeStyle = String.Empty; if (category.ILevel < (group.MaxLevel + 1) && category.HasChild) { nodeStyle = category.IsOpen.ToString(); } strHtml.Append("<tr lv=\"").Append(category.ILevel - 1).Append("\" onoff=\"").Append(nodeStyle).Append("\">"); strHtml.Append("<td align=\"center\"><input type=\"checkbox\" name=\"g1\" value=\"").Append(category.Pkid).Append("\" /></td>"); strHtml.Append("<td><input name=\"title").Append(category.Pkid).Append("\" value=\"").Append(category.Title).Append("\" type=\"text\" class=\"text\" /></td>"); strHtml.Append("<td>").Append(category.Pkid).Append("</td>"); strHtml.Append("<td class=\"gray\">").Append(bll_category.GetStatus(category, "enab")).Append("</td>"); strHtml.Append("<td>").Append(DateHelper.ToShortDate(category.CreateTime)).Append("</td>"); strHtml.Append("<td>"); if (i > 0) { strHtml.Append("<a href=\"javascript:;\" onclick=\"operate('moveup',").Append(category.Pkid).Append(",'").Append(param).Append("');\" class=\"icon icon_moveup\" title=\"上移\"></a>"); } else { strHtml.Append("<a class=\"icon icon_empty\"></a>"); } if (i < categoryList.Count - 1) { strHtml.Append("<a href=\"javascript:;\" onclick=\"operate('movedown',").Append(category.Pkid).Append(",'").Append(param).Append("');\" class=\"icon icon_movedown\" title=\"下移\"></a>"); } else { strHtml.Append("<a class=\"icon icon_empty\"></a>"); } strHtml.Append("<a href=\"categoryEdit.aspx?pkid=").Append(category.Pkid).Append(param).Append("\" class=\"icon icon_edit\" title=\"编辑\"></a>"); strHtml.Append("<div class=\"operation\">"); strHtml.Append("<a href=\"javascript:;\" onclick=\"operate('del',").Append(category.Pkid).Append(",'").Append(param).Append("');\" class=\"icon icon_del\" title=\"删除\"></a>"); strHtml.Append("<div>"); strHtml.Append("</td>"); strHtml.Append("</tr>"); if (category.ILevel < group.MaxLevel + 1) { if (category.HasChild && category.IsOpen) { strHtml.Append(CreateTree(category.Pkid)); } strHtml.Append("<tr lv=\"").Append(category.ILevel).Append("\" rank=\"last\">"); strHtml.Append("<td></td>"); strHtml.Append("<td colspan=\"5\"><a href=\"javascript:;\" onclick=\"addCategory($(this), ").Append(category.Pkid).Append(");\" class=\"icon2 icon_add\"> [").Append(category.Title).Append("] 子类别</a></td>"); strHtml.Append("</tr>"); } } return(strHtml); }
public async Task <IDataResponse <int> > InsertAsync(CategoryModel model) { return(await _dal.InsertAsync(_mapper.Map <Category>(model))); }