public ActionResult Create(Tasks task) { try { if (ModelState.IsValid) { db.AddToTasks(task); db.SaveChanges(); return RedirectToAction("Index"); } } catch(Exception ex) { ModelState.AddModelError(String.Empty, ex); } return View(task); }
/// <summary> /// Deprecated Method for adding a new object to the Tasks EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTasks(Tasks tasks) { base.AddObject("Tasks", tasks); }
/// <summary> /// Create a new Tasks object. /// </summary> /// <param name="taskId">Initial value of the TaskId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="article">Initial value of the Article property.</param> public static Tasks CreateTasks(global::System.Int32 taskId, global::System.String name, global::System.String article) { Tasks tasks = new Tasks(); tasks.TaskId = taskId; tasks.Name = name; tasks.Article = article; return tasks; }
// // GET: /Admin/Create public ActionResult Create() { Tasks task = new Tasks(); return View(task); }