public IHttpActionResult Delete(int id)
        {
            NoteRepository noterepo = new NoteRepository();

            noterepo.Delete(id);
            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public ViewModel()
        {
            repo  = new NoteRepository("ConnStrNotes");
            Notes = new ObservableCollection <Note>(repo.GetNoteList());

            Save = new RelayCommand(x =>
            {
                repo.Save();
            });

            Add = new RelayCommand(x =>
            {
                Note newNote = new Note();
                newNote      = repo.Create(newNote);
                repo.Save();
                Notes.Add(newNote);
            });

            Remove = new RelayCommand(x =>
            {
                int id = Current.Id;
                Notes.Remove(Current);
                repo.Delete(id);
                repo.Save();
            },
                                      x => Notes.Count > 0);
        }
Exemple #3
0
        public void Cannot_Delete_NonExists_Note()
        {
            // Arrange
            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>");
            var note = new HmmNote
            {
                Author      = _author,
                Catalog     = _catalog,
                Description = "testing note",
                Subject     = "testing note is here",
                Content     = xmlDoc.InnerXml,
            };

            NoteRepository.Add(note);
            Assert.True(NoteRepository.ProcessMessage.Success);

            // change the note id to create a new note
            var orgId = note.Id;

            note.Id = 2;

            // Act
            var result = NoteRepository.Delete(note);

            // Assert
            Assert.False(NoteRepository.ProcessMessage.Success);
            Assert.False(result);

            // do this just to make clear up code pass
            note.Id = orgId;
        }
Exemple #4
0
        public void Can_Delete_Note()
        {
            // Arrange
            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>");
            var note = new HmmNote
            {
                Author      = _author,
                Catalog     = _catalog,
                Description = "testing note",
                Subject     = "testing note is here",
                Content     = xmlDoc.InnerXml,
            };

            NoteRepository.Add(note);
            Assert.True(NoteRepository.ProcessMessage.Success);

            // Act
            var result = NoteRepository.Delete(note);

            // Assert
            Assert.True(NoteRepository.ProcessMessage.Success);
            Assert.True(result);
            Assert.False(NoteRepository.GetEntities().Any());
        }
Exemple #5
0
        public ActionResult Delete(long noteId)
        {
            var note = noteRepository.Load(noteId);

            noteRepository.Delete(note);
            return(RedirectToAction("Index"));
        }
Exemple #6
0
        public ActionResult Delete(int id)
        {
            Note note = nr.Find(x => x.Id == id);

            nr.Delete(note);
            return(RedirectToAction("Index"));
        }
Exemple #7
0
        public IActionResult Delete(string title)
        {
            NoteRepository noteRepository = new NoteRepository();

            noteRepository.Delete(title);

            return(returnToIndex());
        }
        private void Remove()
        {
            Note noteToDelete = ChooseNote("Which note would you like to remove?");

            if (noteToDelete != null)
            {
                _noteRepository.Delete(noteToDelete.Id);
            }
        }
Exemple #9
0
        private void Remove()
        {
            Note noteToDelete = Choose();

            if (noteToDelete != null)
            {
                _noteRepository.Delete(noteToDelete.Id);
            }
        }
        public async Task <ActionResult <NoteItem> > Delete(Guid id)
        {
            var note = await noteRepository.Delete(id);

            if (note == null)
            {
                return(NotFound());
            }
            return(note);
        }
Exemple #11
0
        private void RemoveNotes(Notes notes, Currency currency)
        {
            var noteRepository = new NoteRepository(_sqlConnectionProvider);

            foreach (var noteEntity in ConvertToNoteEntities(notes, currency))
            {
                noteRepository.Delete(noteEntity);
            }

            _totalMoney[currency].Notes.Remove(notes);
        }
Exemple #12
0
        public void DeleteNote(int id)
        {
            Note note = repository.Get(id);

            if (note == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            repository.Delete(id);
        }
Exemple #13
0
 public ActionResult Delete(int id)
 {
     if (id > 0)
     {
         Note note = new Note();
         note = NoteRepository.GetByID(id);
         NoteRepository.Delete(note);
     }
     model = new NoteControllerNoteVM();
     TryUpdateModel(model);
     return(RedirectToAction("ListNotes", "Note", new { @parentId = model.ParentContactId }));
 }
Exemple #14
0
        public IActionResult Delete(int id)
        {
            var user = GetCurrentUserProfile();
            var post = _noteRepository.GetById(id);

            if (user.Id != post.UserId)
            {
                return(Forbid());
            }

            _noteRepository.Delete(id);
            return(NoContent());
        }
Exemple #15
0
        public void Delete_Note(object sender, RoutedEventArgs e)
        {
            Note note = (Note)Notes_Listbox.SelectedItem;

            _show_error(Delete_Note_Error_Message, false);

            if (note == null)
            {
                _show_error(Delete_Note_Error_Message, true);
                return;
            }
            note_repo.Delete(note.NoteId);
            _DataBindNotes(Notes_Listbox);
        }
Exemple #16
0
        public void TestNoteDelete()
        {
            List <Project> project_list = project_repo.All();
            var            project      = project_list[0];
            int            project_id   = project.ProjectId;

            note_repo.Add(new Note("this is a test note", project_id));
            note_repo.Add(new Note("this is note 2", project_id));

            int last_note_id = note_repo.GetAllByProjectId(project_id)[0].NoteId;

            Assert.AreEqual(2, note_repo.GetAllByProjectId(project_id).Count);
            note_repo.Delete(last_note_id);
            Assert.AreEqual(1, note_repo.GetAllByProjectId(project_id).Count);
        }
Exemple #17
0
        private void Remove()
        {
            Note noteToDelete = Choose("Which note would you like to delete?");

            if (noteToDelete != null)
            {
                try
                {
                    _noteRepository.Delete(noteToDelete.Id);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Invalid Selection.");
                }
            }
        }
Exemple #18
0
        public void Dispose()
        {
            if (_dbContext is DbContext context)
            {
                context.Reset();
            }

            var systems = LookupRepo.GetEntities <Subsystem>().ToList();

            foreach (var sys in systems)
            {
                SubsystemRepository.Delete(sys);
            }
            var notes = LookupRepo.GetEntities <HmmNote>().ToList();

            foreach (var note in notes)
            {
                NoteRepository.Delete(note);
            }

            var catalogs = LookupRepo.GetEntities <NoteCatalog>().ToList();

            foreach (var catalog in catalogs)
            {
                CatalogRepository.Delete(catalog);
            }

            var renders = LookupRepo.GetEntities <NoteRender>().ToList();

            foreach (var render in renders)
            {
                RenderRepository.Delete(render);
            }

            var authors = LookupRepo.GetEntities <Author>().ToList();

            foreach (var author in authors)
            {
                AuthorRepository.Delete(author);
            }

            if (_dbContext is DbContext newContext)
            {
                newContext.Reset();
            }
            GC.SuppressFinalize(this);
        }
Exemple #19
0
 public IActionResult Delete(int id)
 {
     _noteRepository.Delete(id);
     return(NoContent());
 }
Exemple #20
0
 public int Delete(int id)
 {
     return(_repository.Delete(id));
 }
 public void DeleteNote(Note note)
 {
     _noteRepository.Delete(note);
     OnPropertyChanged(nameof(Notes));
 }
Exemple #22
0
 public void Delete(Guid id)
 {
     NoteRepository.Delete(id);
 }
Exemple #23
0
 public bool Delete(int id)
 {
     return(_noteRepository.Delete(id));
 }