예제 #1
0
        public ActionResult Create(FormCollection form)
        {
            try
            {
                using (var context = new LibraryContainer())
                {
                    var note = new Note();
                    TryUpdateModel(note, new[] { "Title", "Date" });
                    note.Text = HttpUtility.HtmlDecode(form["Text"]);
                    context.AddToNote(note);
                    context.SaveChanges();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
예제 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Note EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToNote(Note note)
 {
     base.AddObject("Note", note);
 }
예제 #3
0
 /// <summary>
 /// Create a new Note object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 public static Note CreateNote(global::System.Int32 id, global::System.String title, global::System.DateTime date)
 {
     Note note = new Note();
     note.Id = id;
     note.Title = title;
     note.Date = date;
     return note;
 }