本文整理汇总了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);
}
}
示例2: Delete
public JsonResult Delete(CategoryModel model)
{
if (ModelState.IsValid)
return Json(_service.Delete(model));
return Json(null);
}
示例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.");
}
}
示例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));
}
示例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();
}
示例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);
}
示例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);
}
示例8: CategoryViewModel
public CategoryViewModel(
CategoryModel categoryModel,
string pageTitle,
INavigationServiceFacade navigationServiceFacade,
bool synchronizedWithSelection)
{
this._category = categoryModel;
this._pageTitle = pageTitle;
this._navigationServiceFacade = navigationServiceFacade;
}
示例9: ToCategoryModel
public static CategoryModel ToCategoryModel(this Category global)
{
CategoryModel category = new CategoryModel
{
Id = global.Id,
Name = global.Name
};
return category;
}
示例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);
}
示例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
};
}
示例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;
}
示例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();
}
示例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));
}
示例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);
}