public ActionResult Create(CheatNote cheatNote, string questionsPlainText) { try { var cheatNoteItems = ParseCheatNoteItems(questionsPlainText); if (cheatNoteItems != null && cheatNoteItems.Count > 0) { foreach (var item in cheatNoteItems) { item.CreatedById = GetCurrentUserId(); } cheatNote.Items = cheatNoteItems; } using (var db = new CheatNotesContext()) { cheatNote.CreatedById = GetCurrentUserId(); db.CheatNotes.Add(cheatNote); db.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(cheatNote); } }
public static IEnumerable<CheatNoteGeneratedHtml> GenerateHtmlFiles(string fileName, CheatNote cheatNote, long? partSize) { if (string.IsNullOrWhiteSpace(fileName) || cheatNote == null || cheatNote.Items == null) { return Enumerable.Empty<CheatNoteGeneratedHtml>(); } var itemsTree = SplitCheatNoteItems(cheatNote.Items.Where(x => !x.DateDeleted.HasValue).OrderBy(x => x.Position), partSize); return itemsTree.Any() ? GenerateHtmlCollection(fileName, cheatNote.Name, itemsTree) : Enumerable.Empty<CheatNoteGeneratedHtml>(); }
public ActionResult Edit(int id, CheatNote cheatNote) { try { using (var db = new CheatNotesContext()) { var instance = db.CheatNotes.Get(id); if (instance != null) { instance.Name = cheatNote.Name; instance.Description = cheatNote.Description; instance.DateModified = DateTime.Now; instance.ModifiedById = GetCurrentUserId(); } db.Entry(instance).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
public GenerateHtmlFilesModel(CheatNote cheatNote) { CheatNoteId = cheatNote.Id; CheatNoteName = cheatNote.Name; CheatNoteItemsTotal = cheatNote.Items.Count; }