public async Task <ActionResult <Models.DTO.NoteDTO> > Post(Models.DTO.NoteDTO note) { Models.Note newNote = null; try { newNote = new Models.Note(note, _dbContext); } catch (Exception ex) { return(BadRequest(ex.Message)); } // Update timestamps newNote.Created = DateTime.Now; newNote.Edited = newNote.Created; _dbContext.Notes.Add(newNote); await _dbContext.SaveChangesAsync(); return(CreatedAtAction( nameof(Get), new { id = newNote.NoteId }, new Models.DTO.NoteDTO(newNote) )); }
/// <summary> /// Get all the files in the container /// </summary> /// <returns></returns> public static IEnumerable <ReadingNotesApiApp.Models.Note> GetAllNotefromStorage() { string containerName = GetNotesContainerName(); CloudBlobClient blobClient = BlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(containerName); var blobs = container.ListBlobs(null, false); var Notes = new Collection <ReadingNotesApiApp.Models.Note>(); foreach (var blobItem in blobs) { string filename = ExtractFileNameFromBlobPath(blobItem, containerName); try { var blockBlob = container.GetBlockBlobReference(filename); string noteData = blockBlob.DownloadText(); Models.Note readNote = JsonConvert.DeserializeObject <ReadingNotesApiApp.Models.Note>(noteData); Notes.Add(readNote); blockBlob.DeleteIfExistsAsync(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(String.Format("Problem with file: {0}. Error: {1}", filename, ex.Message)); } } return(Notes); }
public async Task <ActionResult <Models.Note> > PostTodoItem(Models.Note note) { _context.Notes.Add(note); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetTodoItem), new { id = note.Id }, note)); }
public async Task <ActionResult> Put(int id, Models.DTO.NoteDTO note) { if (id != note.Id) { return(BadRequest($"Query param id {id} must match body data id {note.Id}")); } Models.Note dbNote = _dbContext.Notes .Include(n => n.NoteLabels) .AsTracking() .FirstOrDefault(n => n.NoteId == id); if (dbNote == null) { return(NotFound()); } try { dbNote.SetFrom(note, _dbContext); } catch (Exception ex) { return(BadRequest(ex.Message)); } await _dbContext.SaveChangesAsync(); return(NoContent()); }
private bool DeleteNoteValidRequest(StreamWriter sw) { try { GoogleFirestoreConnectionManager.HandleLogin(userID1, displayName1, email1); Models.Notebook createdNotebook = GoogleFirestoreConnectionManager.CreateNotebook(userID1, notebook1.Title, notebook1.Author, notebook1.Isbn, notebook1.Publisher, notebook1.PublishDate, notebook1.CoverURL); Models.Note createdNote = GoogleFirestoreConnectionManager.CreateNote(userID1, createdNotebook.ID, text1); if (!GoogleFirestoreConnectionManager.DeleteNote(createdNote.ID)) { sw.WriteLine("FAILED: DeleteNote(string noteID): Normal test case 1."); GoogleFirestoreConnectionManager.DeleteUser(userID1); return(false); } else { try { GoogleFirestoreConnectionManager.GetNote(createdNote.ID); } catch (NotFoundException) { GoogleFirestoreConnectionManager.DeleteUser(userID1); return(true); } GoogleFirestoreConnectionManager.DeleteUser(userID1); return(false); } } catch { sw.WriteLine("FAILED: DeleteNote(string noteID): Normal test case 1 - unexpected exception."); return(false); } }
/// <summary> /// Load existing note /// </summary> /// <param name="note"></param> /// <param name="noteModel"></param> /// <param name="deck"></param> public NoteViewModel(Models.Note note, Models.NoteModel noteModel, DeckViewModel deck) { _note = note; _noteModel = noteModel; Deck = deck; Initialize(); }
public ActionResult AddNewNote(Models.Note model) { data.Notes.Add(model); data.SaveChanges(); var notes = data.Notes; return(Redirect("~/")); }
public void AddNote(Models.Note note) { List <Models.Note> Notes = GetNote(); Notes.Add(note); using var writer = File.CreateText(ConfigGetter.GetNotePath()); writer.Write(JsonConvert.SerializeObject(Notes, Formatting.Indented)); }
public NewNotePage() { Item = new Models.Note(noteCreatedCount++) { Title = "Item name", Text = "This is an item description." }; BindingContext = this; }
public void Create(Models.Note noteToAdd, IEnumerable <Models.Category> newCategories) { Note newNote = new Note { Title = noteToAdd.Title, Message = noteToAdd.Message, Added = DateTime.Now }; context.Notes.AddObject(newNote); context.SaveChanges(); UpdateRelation(newNote, newCategories); }
public async Task OnGetAsync(int?idMatiere) { Etudiant = await _context.Etudiants .Include(e => e.Niveau) .ToListAsync(); Note = await _context.Notes .Include(n => n.Etudiant) .Include(n => n.Matiere).ToListAsync(); if (idMatiere != null) { Note = Note.Where(e => e.MatiereID == idMatiere).ToList(); IdMat = (int)idMatiere; Matiere = await _context.Matieres.FindAsync(idMatiere); Matiere Mat = new Matiere(); Mat = _context.Matieres.Find(idMatiere); Module Mod = new Module(); Mod = _context.Modules.Find(Mat.ModuleID); Niveau Niv = new Niveau(); Niv = _context.Nivaux.Find(Mod.NiveauID); Etudiant = Etudiant.Where(e => e.NiveauID == Niv.ID).ToList(); } foreach (Etudiant etudiant in Etudiant) { bool b = false; foreach (Note note in Note) { if (etudiant.ID == note.EtudiantID) { b = true; } } if (b == false) { Note Note2 = new Models.Note(); Note2.EtudiantID = etudiant.ID; Note2.MatiereID = (int)idMatiere; _context.Notes.Add(Note2); } } await _context.SaveChangesAsync(); Note = await _context.Notes .Include(n => n.Etudiant) .Include(n => n.Matiere).ToListAsync(); Note = Note.Where(e => e.MatiereID == idMatiere).OrderBy(n => n.Etudiant.Nom).ToList(); }
private bool CreateNoteNotebookDoesNotExist(StreamWriter sw) { try { Models.Note temp = GoogleFirestoreConnectionManager.CreateNote(userID1, notebookID1 + "NOTEXIST", text1); sw.WriteLine("FAILED: CreateNote(string userID, string notebookID, string noteText): CreateNote Notebook does not exist test case."); GoogleFirestoreConnectionManager.DeleteNote(temp.ID); return(false); } catch { return(true); } }
private bool CreateNoteUserIdIsEmpty(StreamWriter sw) { try { Models.Note temp = GoogleFirestoreConnectionManager.CreateNote("", notebookID1, text1); sw.WriteLine("FAILED: CreateNote(string userID, string notebookID, string noteText): CreateNote userID is empty test case."); GoogleFirestoreConnectionManager.DeleteNote(temp.ID); return(false); } catch { return(true); } }
private bool CreateNoteNoteTextIsNull(StreamWriter sw) { try { Models.Note temp = GoogleFirestoreConnectionManager.CreateNote(userID1, notebookID1, null); sw.WriteLine("FAILED: CreateNote(string userID, string notebookID, string noteText): CreateNote note text is null test case."); GoogleFirestoreConnectionManager.DeleteNote(temp.ID); return(false); } catch { return(true); } }
public async Task <IActionResult> PutNote(long id, Models.Note note) { if (id != note.Id) { return(BadRequest()); } _context.Entry(note).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public ICollection <NoteContent> Resolve(NoteInputDto source, Models.Note destination, ICollection <NoteContent> destMember, ResolutionContext context) { if (source.Content == null) { return(new List <NoteContent>()); } return(Regex.Split(source.Content, @"(?<=\G.{8000})", RegexOptions.Singleline).Select(s => new NoteContent { Id = Guid.NewGuid(), Content = s }).ToList()); }
public string Delete(int noteNumber) { Models.Note note = db.Notes.Find(noteNumber); if (note == null) { return("Fail"); } db.Notes.Remove(note); db.SaveChanges(); return("Ok"); }
public static Note Create(Models.Note note) { return(new Note() { Idnote = note.Idnote, Title = note.Title, Date = note.Date, Description = note.Description, IsMarkdown = note.IsMarkdown, Timestamp = note.Timestamp, Categories = note.NoteCategory.Select(nc => nc.IdcategoryNavigation.Name).ToList(), }); }
public string SetFavourite(int noteNumber, int favourite) { Models.Note note = db.Notes.Find(noteNumber); if (note == null) { return("Fail"); } note.Favourite = favourite; db.Entry(note).State = EntityState.Modified; db.SaveChanges(); return("Ok"); }
public void UpdateNote() { // We don't have a Note-Service, so we work on the Model Models.Note note = new Models.Note { Id = 777, Priority = 3, Title = "New Note", Text = "Test Note", DueDate = DateTime.Now }; note.Title = "Updated Note"; Assert.Equal("Updated Note", note.Title); }
public void AddGrade(object sender, EventArgs e) { WADLAB4.Models.Note nota = new Models.Note(); nota.Materie = Request.Form["nMat"]; nota.Student = long.Parse(Request.Form["cnp"]); nota.Calificativ = Int32.Parse(Request.Form["cnota"]); var db = WADLAB4.Models.ApplicationDbContext.Create(); db.Grades.Add(nota); db.SaveChanges(); db.Dispose(); }
public ActionResult <Models.DTO.NoteDTO> Get(int id) { Models.Note note = _dbContext.Notes .Include(n => n.NoteLabels) .ThenInclude(nl => nl.Label) .FirstOrDefault(n => n.NoteId == id); if (note == null) { return(NotFound()); } return(new Models.DTO.NoteDTO(note)); }
// DELETE: api/Note/5 public async Task Delete(int id) { Models.Note note = await notesBLL.GetNoteByID(id); if (User.IsInRole(note.SubName.ToLower()) || (!string.IsNullOrWhiteSpace(note.ParentSubreddit) && User.IsInRole(note.ParentSubreddit.ToLower()))) { bool outOfNotes = await notesBLL.DeleteNoteForUser(note, User.Identity.Name); snUpdates.DeleteNote(note, outOfNotes); } else { throw new UnauthorizedAccessException("You are not a moderator of that subreddit!"); } }
// POST: api/Note public async Task Post([FromBody] Models.Note value) { if (User.IsInRole(value.SubName.ToLower())) { value.Submitter = User.Identity.Name; value.Timestamp = DateTime.UtcNow; Models.Note insertedNote = await notesBLL.AddNoteForUser(value); snUpdates.SendNewNote(insertedNote); } else { throw new UnauthorizedAccessException("You are not a moderator of that subreddit!"); } }
private void NotesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListBox nt = (ListBox)sender; if (nt.SelectedItem == null) { AddNewNote.IsOpen = false; return; } Models.Note note = (Models.Note)nt.SelectedItem; FlyoutHeader = "Редактирование"; NoteTitleTextBox.Text = note.Title; RichTexBox_NewNote.Document = note.NoteContent; isNewNote = false; AddNewNote.IsOpen = true; }
public string Save(string title, string body, int favourite, int?folder) { Models.Note newNote = new Models.Note(); newNote.UserId = User.Identity.GetUserId(); newNote.Title = title; newNote.Body = body; newNote.DateOfCreation = DateTime.Now; newNote.DateOfChanging = DateTime.Now; newNote.Favourite = favourite; newNote.FolderId = folder; db.Entry(newNote).State = EntityState.Added; db.SaveChanges(); return("Ok"); }
private Note EditNote(Models.Note noteData) { int intId = noteData.Id.AsInt32(); Note noteToEdit = this.context.Notes.FirstOrDefault(n => n.NoteId == intId); if (noteToEdit == null) { return(null); } noteToEdit.Title = noteData.Title; noteToEdit.Message = noteData.Message; context.SaveChanges(); return(noteToEdit); }
public async Task <ActionResult <Models.Note> > SaveNote([FromBody] Models.Note note) { var UserId = this.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value; if (note.Id > 0) { await noteManager.UpdateNote(note); } else { note.IsActive = true; note.CreatedBy = UserId; note.CreatedOn = DateTime.Now; await noteManager.AddNote(note); } return(Ok(new { ReturnMessage = "Note saved successfully", IsSuccess = true, Data = note })); }
public bool Add(Models.Note note) { try { using (var db = new LiteDatabase(liteDBPath)) { // Get a collection (or create, if not exits) var col = db.GetCollection <Note>("notes"); return(col.Insert(note)); } } catch (Exception) { //throw; return(false); } }
/// <summary> /// Create a new note /// </summary> /// <param name="noteModel"></param> /// <param name="deck"></param> public NoteViewModel(Models.NoteModel noteModel, DeckViewModel deck) { _note = new Models.Note() { __type__ = "Note", data = string.Empty, fields = new List <string>(new string[noteModel.flds.Count]), flags = 0, guid = Utils.Guid64(), note_model_uuid = noteModel.crowdanki_uuid, tags = new List <string>() }; _noteModel = noteModel; Deck = deck; Initialize(); }