Esempio n. 1
0
        public IActionResult Reply(int entryId, string contents)
        {
            try
            {
                var userName = User?.Identity?.Name ?? "Anonymous";
                var response = new BlogResponse()
                {
                    //Author = Username,
                    Contents     = contents,
                    BlogEntryId  = entryId,
                    ResponseDate = DateTime.Now
                };


                _blogResponseRepository.CreateBlogResponse(response);
            }

            catch (InvalidOperationException)
            {
                ViewBag.ErrorMessage = "Reply not created.";
            }


            return(RedirectToAction("Index"));
        }
        public IActionResult Reply(int entryId, string contents)
        {
            var userName = User.Identity.Name ?? "Anonymous";
            var response = new BlogResponse()
            {
                Author       = userName,
                Contents     = contents,
                BlogEntryId  = entryId,
                ResponseDate = DateTime.Now
            };

            _blogResponseRepository.CreateBlogResponse(response);

            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var userName = User.Identity.Name;

            userName = (string.IsNullOrEmpty(userName) ? "Anonymous" : userName);
            var response = new BlogResponse()
            {
                Author       = userName,
                Contents     = txtBlogEntryReply.Text,
                BlogEntryId  = _blogEntryId,
                ResponseDate = DateTime.Now
            };
            var repo = new BlogResponseRepository();

            repo.CreateBlogResponse(response);
            Response.Redirect("/Blog");
        }