コード例 #1
0
        /// <summary>
        /// User views one of their notes based on its ID
        /// </summary>
        /// <param name="id">ID of note the user wants to view</param>
        public void OnPostNote(int id)
        {
            var user = _userManager.GetUserAsync(User).Result;

            UserName  = user.UserName;
            FirstName = user.FirstName;
            LastName  = user.LastName;
            Bio       = user.Bio;
            Email     = user.Email;
            Notes     = _notes.GetNotesByUserID(user.Id).Result;
            try
            {
                Note note = _notes.GetNoteByID(id).Result;
                if (!Notes.Contains(note))
                {
                    throw new Exception("You are not the owner of that note");
                }
                string blobText = _blob.GetText(note).Result;
                Ncvm.Note  = note;
                Ncvm.Text  = blobText;
                Ncvm.Title = note.Title;
                byte[] blobImage = _blob.GetImage(note).Result;
                ImageDisplayExtensions.DisplayImage(blobImage);
            }
            catch (Exception)
            {
                TempData["Error"] = "Something went wrong with accessing that note";
            }
        }
コード例 #2
0
ファイル: Admin.cshtml.cs プロジェクト: jimmychang94/Wordify
        /// <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"));
        }