public ActionResult Create(FormCollection collection) { try { Task newTask = new Task(); newTask.title = collection["title"]; newTask.message = collection["message"]; newTask.startTime = DateTime.Parse(collection["startTime"]); newTask.endTime = DateTime.Parse(collection["endTime"]); newTask.interval = collection["interval"]; newTask.recipients = collection["recipients"]; db.AddToTasks(newTask); db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
/// <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(Task task) { base.AddObject("Tasks", task); }
/// <summary> /// Create a new Task object. /// </summary> /// <param name="taskID">Initial value of the taskID property.</param> /// <param name="title">Initial value of the title property.</param> /// <param name="message">Initial value of the message property.</param> /// <param name="startTime">Initial value of the startTime property.</param> /// <param name="endTime">Initial value of the endTime property.</param> /// <param name="interval">Initial value of the interval property.</param> /// <param name="recipients">Initial value of the recipients property.</param> public static Task CreateTask(global::System.Int32 taskID, global::System.String title, global::System.String message, global::System.DateTime startTime, global::System.DateTime endTime, global::System.String interval, global::System.String recipients) { Task task = new Task(); task.taskID = taskID; task.title = title; task.message = message; task.startTime = startTime; task.endTime = endTime; task.interval = interval; task.recipients = recipients; return task; }