/// <summary> /// Add or update a category. /// </summary> /// <param name="model">The category.</param> /// <returns>The category.</returns> public static Category Set(Category model) { var category = Category.Get(model.Id); model.Id = category.Id; if (category.Id == 0) return Category.Add(model); else return Category.Update(model); }
public ActionResult Create() { var _category = new Category(); var category = Mapper.Map<CategoryModel>(_category); var view = new CategoryEditContainer { Category = category }; return View("edit", view); }
/// <summary> /// Add a new category to database. /// </summary> /// <param name="model">The new category.</param> /// <returns>The new category</returns> public static Category Add(Category model) { Database db = new Database(); var @in = Mapper.Map<CategoryDTO>(model); var result = db.CategoryEntity.Add(@in); var @out = Mapper.Map<Category>(result); return @out; }