Example #1
0
 public IActionResult Comment(string text)
 {
     try
     {
         using (MyWebDB DB = new MyWebDB())
         {
             if (User.Identity.IsAuthenticated)
             {
                 var comment = new CommentDoNet
                 {
                     Name        = User.Identity.Name,
                     CommentText = text.Trim(),
                     Date        = DateTime.Now.Date,
                     Time        = DateTime.Now.TimeOfDay
                 };
                 services.AddComment(DB, admRpo, userRpo, comment);
             }
             else
             {
                 var comment = new CommentDoNet
                 {
                     Name        = "UnknownUser",
                     CommentText = text.Trim(),
                     Date        = DateTime.Now.Date,
                     Time        = DateTime.Now.TimeOfDay
                 };
                 services.AddComment(DB, admRpo, userRpo, comment);
             }
         }
         return(RedirectToAction(nameof(UpController.Comment), "Up"));
     }catch
     {
         return(RedirectToAction(nameof(HomeController.Introduction), "Home"));
     }
 }