/// <summary> /// Create a new Category object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="imageSource">Initial value of the ImageSource property.</param> public static Category CreateCategory(global::System.Int32 id, global::System.String name, global::System.String title, global::System.String imageSource) { Category category = new Category(); category.Id = id; category.Name = name; category.Title = title; category.ImageSource = imageSource; return category; }
public ActionResult Create(FormCollection collection) { try { using (var context = new LibraryContainer()) { var category = new Category { ImageSource = "" }; TryUpdateModel(category, new[] { "Name", "Title" }); context.AddToCategory(category); context.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
/// <summary> /// Deprecated Method for adding a new object to the Category EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCategory(Category category) { base.AddObject("Category", category); }