public JsonResult PostComment(int? postcardId, string value,
     string creationTime)
 {
     if (postcardId == null || value == null || creationTime == null)
     {
         return Json(new { success = false }, JsonRequestBehavior.AllowGet);
     }
     Comment newComment = new Comment
     {
         OwnerId = User.Identity.GetUserId(),
         RelatedPostcardId = postcardId,
         Value = value,
         CreationTime = creationTime
     };
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         db.Comments.Add(newComment);
         db.SaveChanges();
     }
     return Json(new { id = newComment.Id }, JsonRequestBehavior.AllowGet);
 }
        private void ProcessMedalsForLikes(Comment comment)
        {
            using (ApplicationDbContext dataBase = new ApplicationDbContext())
            {
                ApplicationUser owner = dataBase.Users.Single(u => u.Id ==
                    comment.OwnerId);
                var likes = comment.Likers.Count > 0 ? comment.Likers.
                Where(l => l.Id != owner.Id).ToList().Count : 0;
                Medal medal = null;

                if (likes >= 15)
                {
                    medal = dataBase.Medals.Single(m => m.Description ==
                        "ForFifteenLikes");
                    if (owner.Medals.SingleOrDefault(m => m.Id == medal.Id) == null)
                    {
                        owner.Medals.Add(medal);
                    }
                }
                else if (likes >= 10)
                {
                    medal = dataBase.Medals.Single(m => m.Description ==
                        "ForTenLikes");
                    if (owner.Medals.SingleOrDefault(m => m.Id == medal.Id) == null)
                    {
                        owner.Medals.Add(medal);
                    }
                }
                else if (likes >= 5)
                {
                    medal = dataBase.Medals.Single(m => m.Description ==
                        "ForFiveLikes");
                    if (owner.Medals.SingleOrDefault(m => m.Id == medal.Id) == null)
                    {
                        owner.Medals.Add(medal);
                    }
                }
                dataBase.SaveChanges();
            }
        }
 public MediaCommentViewModel(Media m, Comment c)
 {
     Media = m;
     Comment = c;
 }