Exemplo n.º 1
0
        //public string CheckUserAlreadyLikedImage(int ProjectId, int userid,string UserID)//Action for check user already like project.
        //{
        //    if (ProjectImageId == 0)
        //    {
        //        ImageLikeAndComment projectLike = (from like in context.ImageLikeAndComments
        //                                           where like.ProjectId == ProjectId && like.UserId == userid && like.PImageLikeId == ProjectImageId
        //                                          select like).FirstOrDefault();
        //        if (projectLike != null)
        //        {
        //            return projectLike.UserId.ToString();
        //        }

        //    }
        //    else
        //    {
        //        ImageLikeAndComment projectLike = (from like in context.ImageLikeAndComments
        //                                           where like.ProjectId == ProjectId && like.UserId == userid && like.PImageLikeId == ProjectImageId
        //                                           select like).FirstOrDefault();
        //        if (projectLike != null)
        //        {
        //            return projectLike.UserId.ToString();
        //        }

        //    }
        //    return string.Empty;
        //}
        #endregion
        #region code for Like Videos
        public string AddLikeVideos(int projectId, string ProjectImageId, string LikeOrDisLike, string UserID, string userId)  //this function is used to save like Videos data in database.their are 5 parameters to pass which are related to project.
        {
            int    usrId        = Convert.ToInt32(userId);
            int    uId          = Convert.ToInt32(UserID);
            int    imgId        = Convert.ToInt32(ProjectImageId);
            string ReturnString = "Success";

            try
            {
                if (context.VideosLikeAndComments.Any(o => o.ProjectId == projectId && o.VideosId == imgId && o.UserId == uId && o.VideosLikeFlag == true))//check duplicate ids in VideosLikeAndComments table.
                {
                    ReturnString = "You Already Liked this Project Videos.";
                }

                else
                {
                    VideosLikeAndComment vidLike = (from likeTb in context.VideosLikeAndComments //fetch videos which are liked by user.
                                                    where likeTb.ProjectId == projectId && likeTb.PVideosId == imgId && likeTb.UserId == uId
                                                    select likeTb).FirstOrDefault();



                    VideosLikeAndComment objvideos = new VideosLikeAndComment();
                    objvideos.VideosId           = imgId;
                    objvideos.UserId             = uId;
                    objvideos.ProjectId          = projectId;
                    objvideos.VideosLikeFlag     = true;
                    objvideos.VideosTestimonials = "";
                    objvideos.cmtVidFlag         = false;

                    context.VideosLikeAndComments.Add(objvideos); // add data in VideosLikeAndComments table.
                    context.SaveChanges();                        //save data in VideosLikeAndComments table.
                }
            }
            catch
            {
                ReturnString = "Fail";
            }
            return(ReturnString);//return a string.
        }
Exemplo n.º 2
0
        //this function is used to save like Videos data in database.their are 5 parameters to pass which are related to project.
        public string AddLikeVideos(int projectId, string ProjectImageId, string LikeOrDisLike, string UserID, string userId)
        {
            int usrId = Convert.ToInt32(userId);
            int uId = Convert.ToInt32(UserID);
            int imgId = Convert.ToInt32(ProjectImageId);
            string ReturnString = "Success";
            try
            {
                if (context.VideosLikeAndComments.Any(o => o.ProjectId == projectId && o.VideosId == imgId && o.UserId == uId && o.VideosLikeFlag == true))//check duplicate ids in VideosLikeAndComments table.
                {
                    ReturnString = "You Already Liked this Project Videos.";

                }

                else
                {
                    VideosLikeAndComment vidLike = (from likeTb in context.VideosLikeAndComments //fetch videos which are liked by user.
                                                    where likeTb.ProjectId == projectId && likeTb.PVideosId == imgId && likeTb.UserId == uId
                                                    select likeTb).FirstOrDefault();

                    VideosLikeAndComment objvideos = new VideosLikeAndComment();
                    objvideos.VideosId = imgId;
                    objvideos.UserId = uId;
                    objvideos.ProjectId = projectId;
                    objvideos.VideosLikeFlag = true;
                    objvideos.VideosTestimonials = "";
                    objvideos.cmtVidFlag = false;

                    context.VideosLikeAndComments.Add(objvideos);// add data in VideosLikeAndComments table.
                    context.SaveChanges(); //save data in VideosLikeAndComments table.
                }
            }
            catch
            {
                ReturnString = "Fail";
            }
            return ReturnString;//return a string.
        }