本文整理汇总了C#中CategoryModel类的典型用法代码示例。如果您正苦于以下问题:C# CategoryModel类的具体用法?C# CategoryModel怎么用?C# CategoryModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CategoryModel类属于命名空间,在下文中一共展示了CategoryModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getCategory
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;
}
开发者ID:smubarak-ali,项目名称:store-angular,代码行数:15,代码来源:ModelToEntityHelper.cs
示例17: Update
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));
}
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:16,代码来源:CategoriesController.cs
示例18: GetBbsBoard
/// <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;
}
开发者ID:91mvc,项目名称:YQCMS,代码行数:20,代码来源:BbsServiceImpl.cs
示例19: MainCategories_Loaded
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();
}
}
开发者ID:sameemir,项目名称:Whistler,代码行数:19,代码来源:MainCategories.xaml.cs
示例20: AllCategories
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;
}
}
开发者ID:AlexBaba,项目名称:Gruppeoppgave-1-Webapplikasjoner,代码行数:20,代码来源:ProductRepo.cs
注:本文中的CategoryModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论