public string AddLikeOrDislike(int ProjectId, string LikeOrDisLike, string Comment, string Null)
        {
            string ReturnString = "Success";

            try
            {
                ProjectLikeDisLike projectLike = (from likeTb in context.ProjectLikeDisLikes
                                                  where likeTb.projectId == ProjectId
                                                  select likeTb).FirstOrDefault();
                if (projectLike != null)
                {
                    int?TotalLike    = projectLike.totalLike;
                    int?TotalDisLike = Convert.ToInt32(projectLike.totalDislike);

                    if (LikeOrDisLike == "Like")
                    {
                        projectLike.totalLike = TotalLike + 1;
                    }
                    else
                    {
                        projectLike.totalDislike = (TotalDisLike + 1).ToString();
                    }
                }
                else
                {
                    ProjectLikeDisLike projectLikeDislike = new ProjectLikeDisLike();
                    projectLikeDislike.projectId = ProjectId;
                    if (LikeOrDisLike == "Like")
                    {
                        projectLikeDislike.totalLike    = 1;
                        projectLikeDislike.totalDislike = "0";
                    }
                    else
                    {
                        projectLikeDislike.totalLike    = 0;
                        projectLikeDislike.totalDislike = "1";
                    }

                    context.ProjectLikeDisLikes.Add(projectLikeDislike);
                }

                ProjectLikeComment projectComent = new ProjectLikeComment();
                projectComent.projectId = ProjectId;
                projectComent.comment   = Comment;
                projectComent.date      = DateTime.Now;

                context.ProjectLikeComments.Add(projectComent);
                context.SaveChanges();
            }
            catch
            {
                ReturnString = "Fail";
            }
            return(ReturnString);
        }
        /// <summary>
        /// Add Like or dislike to Db
        /// </summary>
        /// <returns></returns>
        public string AddLikeOrDislike(int projectId, string LikeOrDisLike, string UserId)
        {
            string ReturnString = "Success";

            try
            {
                if (string.IsNullOrEmpty(CheckUserAlreadyLiked(projectId, Convert.ToInt32(UserId))))
                {
                    ProjectLikeDisLike projectLike = (from likeTb in context.ProjectLikeDisLikes
                                                      where likeTb.projectId == projectId
                                                      select likeTb).FirstOrDefault();
                    if (projectLike != null)
                    {
                        int?TotalLike = projectLike.totalLike;
                        projectLike.totalLike = TotalLike + 1;
                        projectLike.flag      = true;
                    }
                    else
                    {
                        ProjectLikeDisLike projectLikeDislike = new ProjectLikeDisLike();
                        projectLikeDislike.projectId = projectId;
                        projectLikeDislike.totalLike = 1;
                        projectLikeDislike.flag      = true;

                        context.ProjectLikeDisLikes.Add(projectLikeDislike);
                    }

                    context.ProjectLikeHistories.Add(new ProjectLikeHistory()
                    {
                        ProjectId = projectId,
                        userId    = Convert.ToInt32(UserId),
                        likeOn    = DateTime.Now
                    });
                    context.SaveChanges();
                    SendEmailForLikeAndComment(projectId, Convert.ToInt32(UserId), string.Empty);
                }
                else
                {
                    ReturnString = "You Already Liked this Project";
                }
            }
            catch
            {
                ReturnString = "Fail";
            }
            return(ReturnString);
        }
        /// <summary>
        /// Add Like or dislike to Db
        /// </summary>
        /// <returns></returns>
        public string AddLikeOrDislike(int projectId, string LikeOrDisLike, string UserId)
        {
            string ReturnString = "Success";
            try
            {
                if (string.IsNullOrEmpty(CheckUserAlreadyLiked(projectId, Convert.ToInt32(UserId))))
                {
                    ProjectLikeDisLike projectLike = (from likeTb in context.ProjectLikeDisLikes
                                                      where likeTb.projectId == projectId
                                                      select likeTb).FirstOrDefault();
                    if (projectLike != null)
                    {
                        int? TotalLike = projectLike.totalLike;
                        projectLike.totalLike = TotalLike + 1;
                        projectLike.flag = true;
                    }
                    else
                    {
                        ProjectLikeDisLike projectLikeDislike = new ProjectLikeDisLike();
                        projectLikeDislike.projectId = projectId;
                        projectLikeDislike.totalLike = 1;
                        projectLikeDislike.flag = true;

                        context.ProjectLikeDisLikes.Add(projectLikeDislike);
                    }

                    context.ProjectLikeHistories.Add(new ProjectLikeHistory()
                    {
                        ProjectId = projectId,
                        userId = Convert.ToInt32(UserId),
                        likeOn = DateTime.Now
                    });
                    context.SaveChanges();
                    SendEmailForLikeAndComment(projectId, Convert.ToInt32(UserId), string.Empty);
                }
                else
                {
                    ReturnString = "You Already Liked this Project";
                }
            }
            catch
            {
                ReturnString = "Fail";
            }
            return ReturnString;
        }
        public string AddLikeOrDislike(int ProjectId, string LikeOrDisLike, string Comment, string Null)
        {
            string ReturnString = "Success";
            try
            {
                ProjectLikeDisLike projectLike = (from likeTb in context.ProjectLikeDisLikes
                                                  where likeTb.projectId == ProjectId
                                                  select likeTb).FirstOrDefault();
                if (projectLike != null)
                {
                    int? TotalLike = projectLike.totalLike;
                    int? TotalDisLike = Convert.ToInt32(projectLike.totalDislike);

                    if (LikeOrDisLike == "Like")
                        projectLike.totalLike = TotalLike + 1;
                    else
                        projectLike.totalDislike = (TotalDisLike + 1).ToString();

                }
                else
                {
                    ProjectLikeDisLike projectLikeDislike = new ProjectLikeDisLike();
                    projectLikeDislike.projectId = ProjectId;
                    if (LikeOrDisLike == "Like")
                    {
                        projectLikeDislike.totalLike = 1;
                        projectLikeDislike.totalDislike = "0";
                    }
                    else
                    {
                        projectLikeDislike.totalLike = 0;
                        projectLikeDislike.totalDislike = "1";
                    }

                    context.ProjectLikeDisLikes.Add(projectLikeDislike);
                }

                ProjectLikeComment projectComent = new ProjectLikeComment();
                projectComent.projectId = ProjectId;
                projectComent.comment = Comment;
                projectComent.date = DateTime.Now;

                context.ProjectLikeComments.Add(projectComent);
                context.SaveChanges();
            }
            catch
            {
                ReturnString = "Fail";
            }
            return ReturnString;
        }