Exemple #1
0
        /// <summary>
        /// delete a note based on its ID
        /// </summary>
        /// <param name="id">ID of note to be delted</param>
        /// <returns>admin page</returns>
        public IActionResult OnPostDeleteNote(int id)
        {
            Note note = _note.GetNoteByID(id).Result;

            _blob.DeleteBlob(note);
            _note.DestroyNote(id);
            return(RedirectToPage("/Admin"));
        }
        /// <summary>
        /// User deletes their note based on the notes ID
        /// </summary>
        /// <param name="id">ID of not to be deleted</param>
        /// <returns>profile page with one less note, or error</returns>
        public IActionResult OnPostDeleteNote(int id)
        {
            var  user = _userManager.GetUserAsync(User).Result;
            Note note = _notes.GetNoteByID(id).Result;

            if (note.UserID != user.Id)
            {
                TempData["Error"] = "You are not the owner of that note";
                return(Page());
            }
            _blob.DeleteBlob(note);
            _notes.DestroyNote(id);
            return(RedirectToPage("/Profile"));
        }