Пример #1
0
        public ActionResult SubmitLikeDislike(int videoId, bool isLike)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Json(new { message = "redirect" }, JsonRequestBehavior.AllowGet));
            }


            using (treca_aplikacija_model db = new treca_aplikacija_model())
            {
                UserViewModel user = ApplicationUtils.FindUserByUsername(User.Identity.GetApplicationUserUsername());
                try
                {
                    ApplicationUtils.RemoveLikeDislike(true, videoId, user.users_id);
                }
                catch (Exception)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                video_like_dislike newVld = new video_like_dislike();
                newVld.users_id = (byte)user.users_id;
                newVld.video_id = (byte)videoId;
                newVld.is_like  = isLike == true ? true : false;
                db.video_like_dislike.Add(newVld);
                db.SaveChanges();
            }
            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
 public ActionResult RemoveLikeDislike(int videoId)
 {
     using (treca_aplikacija_model db = new treca_aplikacija_model())
     {
         UserViewModel user = ApplicationUtils.FindUserByUsername(User.Identity.GetApplicationUserUsername());
         try
         {
             ApplicationUtils.RemoveLikeDislike(true, videoId, user.users_id);
         }
         catch (Exception)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
     }
     return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
 }