public ActionResult CreateEntry(EntryModel model) { if (ModelState.IsValid) { String strUser = User.Identity.Name; // Getting the username from session var result = monster.getProfileByUserName(strUser); // Fetching the user's profile model.userId = result.UserId; // Putting the profile's userId into the EntryModel monster.addEntry(model); return RedirectToAction("Entries", "Admin"); } return View(model); }
/// <summary> /// Inserting a new entry into the database. /// Takes an EntryModel object and copies its data into a new Entry object which is /// inserted into the database. /// </summary> /// <param name="entry">The entry object from the page form.</param> public void addEntry(EntryModel entry) { Entry e = new Entry(); e.posted = DateTime.Now; e.added_by = entry.userId; e.title = entry.title; e.content = entry.content; e.category = entry.category; e.entry_type = entry.entry_type; e.entry_status = entry.entry_status; db.Entries.InsertOnSubmit(e); db.SubmitChanges(); }
public void addEntry(EntryModel entry) { }
public ActionResult EditEntry(EntryModel entryModel) { if (ModelState.IsValid) { Entry entry = new Entry(); entry.title = entryModel.title; entry.content = entryModel.content; entry.category = entryModel.category; entry.entry_type = entryModel.entry_type; entry.entry_status = entryModel.entry_status; entry.ID = entryModel.id; monster.updateEntry(entry); return RedirectToAction("Entries", "Admin"); } return View(entryModel); }
public ActionResult EditEntry(int? id) { if (id.HasValue) { int realId = id.Value; Entry entry = monster.getEntryById(realId); if (entry != null) { // Move the Entry to EntryModel EntryModel entryModel = new EntryModel(); entryModel.title = entry.title; entryModel.content = entry.content; entryModel.category = entry.category; entryModel.entry_type = entry.entry_type; entryModel.entry_status = entry.entry_status; return View(entryModel); } } return View("Error"); }