public IActionResult seePost(string textBox, CommentsDB list, int submit, string user, string btnSubmit, int commentId)
        {
            if (btnSubmit != null)
            {
                switch (btnSubmit)
                {
                case "editPost":
                    return(RedirectToAction("editPost", new { Id = submit }));

                case "deletePost":
                    list.deletePost(submit);
                    return(RedirectToAction("seePost", new { submit = submit }));

                case "editComment":
                    return(RedirectToAction("editComment", new { Id = commentId }));

                case "deleteComment":
                    list.deleteComment(commentId);
                    return(RedirectToAction("seePost", new { submit = submit }));
                }
            }

            if (textBox != null && user != null)
            {
                list.addComment(submit, user, textBox);
            }
            else
            {
                Models.ErrorViewModel error = new Models.ErrorViewModel();
                error.RequestId = "Create comment error, one of the required values was empty";
                return(View("Error", error));
            }
            return(RedirectToAction("seePost", new { submit = submit }));
        }
Пример #2
0
        public IActionResult Index(int statusCode)
        {
            var evm = new Models.ErrorViewModel();

            ViewBag.StatusCode = statusCode;
            return(View("Error", evm));
        }
Пример #3
0
        public IActionResult Error(string message)
        {
            var viewModel = new Models.ErrorViewModel
            {
                Message   = message,
                RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
            };

            return(View(viewModel));
        }
Пример #4
0
        /// <summary>
        /// Returns a model.
        /// </summary>
        /// <returns>Model.</returns>
        private Models.ErrorViewModel GetModel()
        {
            Models.ErrorViewModel ret = new Models.ErrorViewModel();
            System.Net.HttpStatusCode code = System.Net.HttpStatusCode.InternalServerError;

            Enum.TryParse<System.Net.HttpStatusCode>(Infrastructure.Utilities.Input.GetString(base.RouteData.Values["id"]), out code);
            ret.Code = code;

            return ret;
        }
 public IActionResult createPost(PostMapDB list, string user, string textBox, string postName)
 {
     if (user != null && textBox != null && postName != null)
     {
         int post = list.addpost(user, textBox, postName);
         return(RedirectToAction("seePost", new { submit = post }));
     }
     else
     {
         Models.ErrorViewModel error = new Models.ErrorViewModel();
         error.RequestId = "Create post error, one of the required values was empty";
         return(View("Error", error));
     }
 }