Ejemplo n.º 1
0
 public ActionResult PostComment(string id, PostCommentBindingModel model)
 {
     NavbarInfo();
     if (Request.IsAuthenticated)
     {
         var    userId     = User.Identity.GetUserId();
         var    user       = this.userService.FindUser(userId);
         Guid   g          = Guid.NewGuid();
         string GuidString = Convert.ToBase64String(g.ToByteArray());
         GuidString = GuidString.Replace("=", "");
         var     pronostic = this.tipsService.FindPronosticById(id);
         Comment comment   = new Comment
         {
             Id          = g.ToString(),
             Message     = model.Comment,
             UserId      = user.Id,
             PronosticId = pronostic.Id,
             Pronostic   = pronostic,
             User        = user,
             TimePosted  = DateTime.Now
         };
         this.tipsService.InsertOrUpdate(comment);
         this.tipsService.SaveChanges();
         var resultPronostic = this.tipsService.FindPronosticById(pronostic.Id);
         var coment          = new
         {
             Id            = comment.Id,
             Message       = comment.Message,
             UserId        = comment.UserId,
             PronosticId   = comment.PronosticId,
             TimePosted    = comment.TimePostedComment,
             TotalComments = pronostic.OwnerComments.Count
         };
         var json = JsonConvert.SerializeObject(coment);
         return(Json(json));
     }
     return(RedirectToAction("Login", "Account"));
 }
Ejemplo n.º 2
0
 public ActionResult EditComment(string id, PostCommentBindingModel pcbm)
 {
     this.adminCommentService.EditComment(id, pcbm);
     return(RedirectToAction("Comments", "Admin"));
 }