当前位置: 首页>>代码示例>>C#>>正文


C# CategoryModel类代码示例

本文整理汇总了C#中CategoryModel的典型用法代码示例。如果您正苦于以下问题:C# CategoryModel类的具体用法?C# CategoryModel怎么用?C# CategoryModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CategoryModel类属于命名空间,在下文中一共展示了CategoryModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddCategory

        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);
            }
        }
开发者ID:dradkins,项目名称:drnajeebvideos,代码行数:27,代码来源:CategoryController.cs

示例2: Delete

        public JsonResult Delete(CategoryModel model)
        {
            if (ModelState.IsValid)
                return Json(_service.Delete(model));

            return Json(null);
        }
开发者ID:Kylia669,项目名称:werehouse,代码行数:7,代码来源:CategoryController.cs

示例3: SaveChanges

        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.");
            }
        }
开发者ID:Edjo,项目名称:MvcProject,代码行数:26,代码来源:CategoryController.cs

示例4: Delete

        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));
        }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:7,代码来源:CategoriesController.cs

示例5: CreateNewEntity

 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();
 }
开发者ID:Jork,项目名称:Billboard,代码行数:8,代码来源:ICategoryConverter.cs

示例6: Should_not_have_error_when_pageSizeOptions_is_null_or_empty

 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);
 }
开发者ID:RobinHoody,项目名称:nopCommerce,代码行数:8,代码来源:CategoryValidatorTests.cs

示例7: btnSubmit_Click

    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);
    }
开发者ID:alicezhuwy,项目名称:Asp.net-webshop,代码行数:8,代码来源:ManageCategory.aspx.cs

示例8: CategoryViewModel

 public CategoryViewModel(
             CategoryModel categoryModel, 
             string pageTitle, 
             INavigationServiceFacade navigationServiceFacade, 
             bool synchronizedWithSelection)
 {
     this._category = categoryModel;
     this._pageTitle = pageTitle;
     this._navigationServiceFacade = navigationServiceFacade;
 }
开发者ID:Rakoun,项目名称:librometer,代码行数:10,代码来源:CategoryViewModel.cs

示例9: ToCategoryModel

        public static CategoryModel ToCategoryModel(this Category global)
        {
            CategoryModel category = new CategoryModel
            {
                Id = global.Id,
                Name = global.Name
            };

            return category;
        }
开发者ID:Rakoun,项目名称:librometer,代码行数:10,代码来源:CategoryMapper.cs

示例10: Edit

        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);
        }
开发者ID:Kylia669,项目名称:werehouse,代码行数:10,代码来源:CategoryController.cs

示例11: CreateProduct

 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
     };
 } 
开发者ID:SanderBouwman,项目名称:KantoorInrichting,代码行数:11,代码来源:ProductFactory.cs

示例12: GetByName

 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;
 }
开发者ID:Zakemi,项目名称:Articles,代码行数:12,代码来源:CategoryService.cs

示例13: Edit

        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();

        }
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:13,代码来源:CategoriesController.cs

示例14: Create

        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));
        }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:13,代码来源:CategoriesController.cs

示例15: Because_of

        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);
        }
开发者ID:GeertVL,项目名称:AutoMapper,代码行数:14,代码来源:MaxDepthTests.cs


注:本文中的CategoryModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。