/// <summary> /// Add LikeImages in Db /// </summary> /// <returns>string</returns> public string AddLikeImages(int projectId, string ProjectImageId, string LikeOrDisLike, string UserID, string userId) //this function is used to save like Image 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.ImageLikeAndComments.Any(o => o.ProjectId == projectId && o.ImageId == imgId && o.UserId == uId && o.ImgLikeFlag == true))//check duplicate ids in ImageLikeAndComments table. { ReturnString = "You Already Liked this Project"; } else { ImageLikeAndComment imgLike = (from likeTb in context.ImageLikeAndComments //fetch image which are liked by user. where likeTb.ProjectId == projectId && likeTb.PImageLikeId == imgId && likeTb.UserId == uId select likeTb).FirstOrDefault(); ImageLikeAndComment objimag = new ImageLikeAndComment(); objimag.ImageId = imgId; objimag.UserId = uId; objimag.ProjectId = projectId; objimag.ImgLikeFlag = true; objimag.ImageTestimonials = ""; objimag.CmtImgFlag = false; context.ImageLikeAndComments.Add(objimag); // add data in ImageLikeAndComments table. context.SaveChanges(); //save data in ImageLikeAndComments table. } } catch { ReturnString = "Fail"; } return(ReturnString); }
//this function is used to save like Image data in database.their are 5 parameters to pass which are related to project. /// <summary> /// Add LikeImages in Db /// </summary> /// <returns>string</returns> public string AddLikeImages(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.ImageLikeAndComments.Any(o => o.ProjectId == projectId && o.ImageId == imgId && o.UserId == uId && o.ImgLikeFlag == true))//check duplicate ids in ImageLikeAndComments table. { ReturnString = "You Already Liked this Project"; } else { ImageLikeAndComment imgLike = (from likeTb in context.ImageLikeAndComments //fetch image which are liked by user. where likeTb.ProjectId == projectId && likeTb.PImageLikeId == imgId && likeTb.UserId == uId select likeTb).FirstOrDefault(); ImageLikeAndComment objimag = new ImageLikeAndComment(); objimag.ImageId = imgId; objimag.UserId = uId; objimag.ProjectId = projectId; objimag.ImgLikeFlag = true; objimag.ImageTestimonials = ""; objimag.CmtImgFlag = false; context.ImageLikeAndComments.Add(objimag);// add data in ImageLikeAndComments table. context.SaveChanges(); //save data in ImageLikeAndComments table. } } catch { ReturnString = "Fail"; } return ReturnString; }