// GET: Note public ActionResult Index() { //var model = new NoteListItemModel[0]; var model = new NoteListItem[0]; return(View(model)); }
// GET ALL NOTES BY CHOREID -- not the best way to do this public IEnumerable <NoteListItem> GetNotesByChoreId(int id) { using (var ctx = new ApplicationDbContext()) { var query = ctx .Notes .ToList(); List <NoteListItem> noteListItems = new List <NoteListItem>(); foreach (Note item in query) { if (item.ChoreId == id) { NoteListItem note = new NoteListItem { NoteId = item.NoteId, ChoreId = item.ChoreId, UserName = item.UserName, NoteTitle = item.NoteTitle, NoteText = item.NoteText, CreatedUtc = item.CreatedUtc, ModifiedUtc = item.ModifiedUtc }; noteListItems.Add(note); } } return(noteListItems); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,NoteId,NoteListItem1,CreatedOn,CreatedBy")] NoteListItem noteListItem) { if (id != noteListItem.Id) { return(NotFound()); } if (ModelState.IsValid) { try { noteListItem.CreatedBy = User.Identity.Name; noteListItem.CreatedOn = DateTime.Now; _dbWrite.Update(noteListItem); await _dbWrite.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NoteListItemExists(noteListItem.Id)) { return(NotFound()); } else { throw; } } noteId = 0; return(RedirectToAction("Index", "NoteListItems", new { Id = noteListItem.NoteId })); } ViewData["NoteId"] = new SelectList(_context.Note, "Id", "Id", noteListItem.NoteId); return(View(noteListItem)); }
public NoteEditControl() { InitializeComponent(); _inEditMode = false; _externalNote = new NoteListItem(); _internalNote = new NoteListItem(); noteEditGrid.DataContext = _internalNote; }
protected void ClearNote(NoteListItem note) { if (note == null) { return; } note.Data.Title = ""; note.Data.Body = ""; }
public ActionResult <NoteListItem> NoteGet(Guid rowGuid) { CU_B_NOTE Item = DBContext.CU_B_NOTE.FirstOrDefault(E => E.ROWGUID == rowGuid); if (Item == null) { throw new NotFoundException($"No note found with RowGuid:{rowGuid}"); } NoteListItem Result = EntityMapper.Map <NoteListItem, CU_B_NOTE>(DBContext, Item); return(Result); }
public void UpdateNote(NoteListItem note) { var item = _notes.Where(x => x.Id == note.Id).FirstOrDefault(); if (item != null) { item.SyncStatus = note.SyncStatus; item.Merged = note.Merged; item.CurrentVersionNum = note.CurrentVersionNum; item.CreatedUTC = note.CreatedUTC; item.ModifiedUTC = note.ModifiedUTC; item.Data.Title = note.Data.Title; item.Data.Body = note.Data.Body; } }
public async Task <IActionResult> Create([Bind("Id,NoteId,NoteListItem1,CreatedOn,CreatedBy")] NoteListItem noteListItem) { if (ModelState.IsValid) { noteListItem.CreatedBy = User.Identity.Name; noteListItem.CreatedOn = DateTime.Now; _dbWrite.Add(noteListItem); await _dbWrite.SaveChangesAsync(); noteId = 0; return(RedirectToAction("Index", "NoteListItems", new { Id = noteListItem.NoteId })); } ViewData["NoteId"] = new SelectList(_context.Note, "Id", "Id", noteListItem.NoteId); return(View(noteListItem)); }
protected void CopyNote(NoteListItem source, NoteListItem dest) { if (dest == null) { return; } if (source == null) { ClearNote(dest); } else { dest.Data.Title = source.Data.Title; dest.Data.Body = source.Data.Body; } }
public void AddNote() { leftTabControl.SelectedIndex = 0; noteListControl.SelectNoteId(null); var newNote = new NoteListItem() { Id = String.Empty, CurrentVersionNum = 0 }; newNote.Data.Title = String.Empty; newNote.Data.Body = String.Empty; noteEditorControl.Note = newNote; noteEditorControl.SetEditMode(); }
public void OnSelectNote(NoteListItem listItem) { selecListItem = listItem; if (selecListItem != null && selecListItem.Note == null) { selecListItem = null; } if (selecListItem == null) { noteText.text = ""; } else { noteText.text = selecListItem.Note.Text; } FillList(); }
protected List <NoteListItem> GetSynchedNotes(string notebookId, SQLiteConnection conn) { var list = new List <NoteListItem>(); var sql = "SELECT n.id, n.sync_status, n.merged, n.deleted, n.current_version_num, n.created_utc, n.deleted_utc, v.created_utc, v.data " + "FROM Note n " + "LEFT OUTER JOIN NoteVersion v ON ((n.id = v.note_id) AND (n.current_version_num = v.version_num)) " + "WHERE n.notebook_id = @notebook_id " + "AND n.sync_status == @sync_status"; var cmd = new SQLiteCommand(sql, conn); cmd.Parameters.AddWithValue("@notebook_id", notebookId); cmd.Parameters.AddWithValue("@sync_status", NoteSyncStatus.Synched); var reader = cmd.ExecuteReader(); try { while (reader.Read()) { var note = new NoteListItem(); note.Id = reader.GetString(0); note.SyncStatus = (NoteSyncStatus)reader.GetInt32(1); note.Merged = reader.GetBoolean(2); note.Deleted = reader.GetBoolean(3); note.CurrentVersionNum = reader.GetInt32(4); note.CreatedUTC = reader.GetDateTime(5); note.DeletedUTC = reader.IsDBNull(6) ? null : new Nullable <DateTime>(reader.GetDateTime(6)); note.ModifiedUTC = reader.GetDateTime(7); note.Data.AsString = reader.GetString(8); list.Add(note); } } finally { reader.Close(); } return(list); }
// ADDED METHOD public List <NoteListItem> ConvertDataEntitiesToViewModel(List <Note> notes) { // instantiate a new List<NoteListItem>** List <NoteListItem> returnList = new List <NoteListItem>(); // foreach through my entity.AllNotes foreach (var note in notes) { //create a new NoteListItem var noteListItem = new NoteListItem(); // assign it the values from the entity.AllNotes[i], noteListItem.NoteId = note.NoteId; noteListItem.NoteTitle = note.NoteTitle; noteListItem.NoteText = note.NoteText; noteListItem.CreatedUtc = note.CreatedUtc; // add NoteListItem to my List<NoteListItem>** returnList.Add(noteListItem); } // return that List<NoteListItem>** return(returnList); }
public void AddNote(NoteListItem note) { _notes.Add(note); SelectNoteId(note.Id); }