public AdminController(IAuthProvider authProvider, TeamSqlDAL teamDAL, IUserDAL userDAL, MessagesDAL messageDAL)
 {
     this.authProvider = authProvider;
     this.teamDAL      = teamDAL;
     this.userDAL      = userDAL;
     this.messageDAL   = messageDAL;
 }
        public static LeftMenuViewModel Get(User user, string selectedMenu)
        {
            var result = new LeftMenuViewModel()
            {
                CompanyNameWithTypeOfOwnership = user.CompanyNameWithTypeOfOwnership,
                Rating           = user.Rating.ToString(),
                RatingImagesHtml = user.RatingImagesHtml,
                SelectedMenu     = selectedMenu,
                CurrentUserId    = user.Id
            };

            if (user.SmallPhotoUrl != null)
            {
                result.SmallPhotoUrl = user.SmallPhotoUrl;
            }
            else
            {
                //var photos = PhotosDAL.GetCompanyLogoGroup(user.Id).OrderBy(p => p.Width).ToList();
                //result.SmallPhotoUrl = photos.Any() ? photos.First().Url : PhotoHelper.NoLogoImageUrl;
                user.LogoGroup       = PhotosDAL.GetCompanyLogoGroup(user.Id);
                result.SmallPhotoUrl = user.GetBestFitLogoPhoto(1).Url;
            }

            result.AdsCount            = AdsDAL.GetAdsCount((int)AdStatuses.Published, user.Id);
            result.UnreadMessagesCount = MessagesDAL.GetUnreadMessagesCount(user.Id);

            return(result);
        }
Example #3
0
        public static string[] GetCompletionList(string prefixText, int count)
        {
            string encrypFriendID = null;

            if (count == 0)
            {
                count = 10;
            }

            MessagesDAL   member  = new MessagesDAL();
            List <Member> members = member.SearchMember(prefixText);

            List <string> items = new List <string>(count);


            foreach (var element in members)
            {
                encrypFriendID = element.MemberId;
                // items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(element.DisplayName, encrypFriendID));
            }



            return(items.ToArray());
        }
        public string GetAllTags(int postID)
        {
            Post p;

            StringBuilder allTags = new StringBuilder();
            MessagesDAL   member  = new MessagesDAL();
            List <Member> members = tagDAL.GetTagedFriends(p = new Post(postID));

            List <Member> poster = tagDAL.GetPostMemberID(p = new Post(postID));

            foreach (var element in members)
            {
                string m = Session["memberID"].ToString();

                if (poster[0].MemberId == Session["memberID"].ToString())
                {
                    allTags.Append("<li ><a id='" + element.MemberId + "' class='btnMemberProfile pointer'>" + element.DisplayName + "</a><a class='button left big floatright btnUntag ' style='margin: 0;' >Untag friend</a></li>");
                }
                else if (element.MemberId == Session["memberID"].ToString())
                {
                    allTags.Append("<li ><a id='" + element.MemberId + "' class='btnMemberProfile pointer'>" + element.DisplayName + "</a><a class='button left big floatright btnUntag ' style='margin: 0;' >Untag yourself</a></li>");
                }
                else
                {
                    allTags.Append("<li ><a id='" + element.MemberId + "' class=' btnMemberProfile pointer'>" + element.DisplayName + "</a></li>");
                }
            }

            return(allTags.ToString());
        }
        public static string DeleteMessage(int messageID)
        {
            Messages message = new Messages(messageID);

            MessagesDAL test = new MessagesDAL();
            test.DeleteMessage(message);

            return "true";
        }
Example #6
0
        public static string DeleteMessage(int messageID)
        {
            Messages message = new Messages(messageID);

            MessagesDAL test = new MessagesDAL();

            test.DeleteMessage(message);


            return("true");
        }
        public void DeleteMessages(string messageIDs)
        {
            string[] tempArray = messageIDs.Split('_');

            MessagesDAL test = new MessagesDAL();

            for (int x = 1; x < tempArray.Length; ++x)
            {
                Messages message = new Messages(int.Parse(tempArray[x]));
                test.DeleteMessage(message);
            }
        }
Example #8
0
        public void DeleteMessages(string messageIDs)
        {
            string[] tempArray = messageIDs.Split('_');

            MessagesDAL test = new MessagesDAL();

            for (int x = 1; x < tempArray.Length; ++x)
            {
                Messages message = new Messages(int.Parse(tempArray[x]));
                test.DeleteMessage(message);
            }
        }
Example #9
0
        public List <AutoCompleteDTO> GetAllMembers(string prefixTxt)
        {
            //GetCompletionList

            MessagesDAL   member  = new MessagesDAL();
            List <Member> members = member.SearchMember(prefixTxt);
            List <Group>  groups  = member.SearchGroup(prefixTxt);

            AutoCompleteDTO        auto;
            List <AutoCompleteDTO> items = new List <AutoCompleteDTO>();

            string[,] mmb = new string[1, 2];


            //ADDING MEMBERS TO LIST
            foreach (var element in members)
            {
                if (element.MemberId == HttpContext.Current.Session["memberID"].ToString())
                {
                    //DO NOT ADD
                }
                else
                {
                    auto = new AutoCompleteDTO(element.MemberId, element.DisplayName, "People");
                    items.Add(auto);
                }
            }

            //ADDING GROUPS TO LIST
            foreach (var element in groups)
            {
                if (element.MemberId == HttpContext.Current.Session["memberID"].ToString())
                {
                    //DO NOT ADD
                }
                else
                {
                    auto = new AutoCompleteDTO(element.GroupId.ToString(), element.GroupDescription, "Groups");
                    items.Add(auto);
                }
            }

            return(items);
        }
Example #10
0
        public List<AutoCompleteDTO> GetAllMembers(string prefixTxt)
        {
            //GetCompletionList

            MessagesDAL member = new MessagesDAL();
            List<Member> members = member.SearchMember(prefixTxt);
            List<Group> groups = member.SearchGroup(prefixTxt);

            AutoCompleteDTO auto;
            List<AutoCompleteDTO> items = new List<AutoCompleteDTO>();
            string[,] mmb = new string[1, 2];

            //ADDING MEMBERS TO LIST
            foreach (var element in members)
            {
                if (element.MemberId == HttpContext.Current.Session["memberID"].ToString())
                {
                    //DO NOT ADD
                }
                else
                {
                    auto = new AutoCompleteDTO(element.MemberId, element.DisplayName, "People");
                    items.Add(auto);
                }

            }

            //ADDING GROUPS TO LIST
            foreach (var element in groups)
            {
                if (element.MemberId == HttpContext.Current.Session["memberID"].ToString())
                {
                    //DO NOT ADD
                }
                else
                {
                    auto = new AutoCompleteDTO(element.GroupId.ToString(), element.GroupDescription, "Groups");
                    items.Add(auto);
                }

            }

            return items;
        }
Example #11
0
        public string[] GetNxtPre(int messageID, string condition)
        {
            MessagesDAL test   = new MessagesDAL();
            Member      member = new Member();

            member.MemberId = Context.Session["memberID"].ToString();
            m.MemberId      = Session["memberID"].ToString();
            inbox           = test.getInboxList(m);

            Messages message = new Messages();



            message.MessageId = messageID;
            int[] index = test.GetMessageIndex(message, member);
            //int[] index = { 0, 0 };



            if (condition == "pre")
            {
                inbox = test.GetPreviousMessage(message, member);
            }
            else
            {
                inbox = test.GetNextMessage(message, member);
            }

            string concatinater = BuildSingleMessage(inbox);

            if (concatinater == "")
            {
                Message msg = new Message(messageID);

                inbox        = test.GetAMessage(msg);
                concatinater = BuildSingleMessage(inbox);
            }

            string[] singleView = new string[] { index[0].ToString(), index[1].ToString(), concatinater };

            return(singleView);
        }
Example #12
0
        public List<AutoCompleteDTO> GetAllFriends(string prefixTxt)
        {
            //GetCompletionList

            MessagesDAL member = new MessagesDAL();
            List<Member> members = member.SearchMember(prefixTxt);
            AutoCompleteDTO auto;
            List<AutoCompleteDTO> items = new List<AutoCompleteDTO>();
            string[,] mmb = new string[1,2];

            foreach (var element in members)
            {

                auto = new AutoCompleteDTO(element.MemberId, element.DisplayName);
                items.Add(auto);

            }

            return items;
        }
Example #13
0
        public List <AutoCompleteDTO> GetAllFriends(string prefixTxt)
        {
            //GetCompletionList

            MessagesDAL            member  = new MessagesDAL();
            List <Member>          members = member.SearchMember(prefixTxt);
            AutoCompleteDTO        auto;
            List <AutoCompleteDTO> items = new List <AutoCompleteDTO>();

            string[,] mmb = new string[1, 2];



            foreach (var element in members)
            {
                auto = new AutoCompleteDTO(element.MemberId, element.DisplayName);
                items.Add(auto);
            }

            return(items);
        }
Example #14
0
        public static int AddMessage(Message message)
        {
            #region Проверка заполненности обязательных полей
            if (message.SenderId == 0)
            {
                throw new Exception("Не заполнено необходимое поле SenderId");
            }

            if (message.RecipientId == 0)
            {
                throw new Exception("Не заполнено необходимое поле RecipientId");
            }
            #endregion

            if (message.Date == DateTime.MinValue)
            {
                message.Date = DateTime.Now.ToUniversalTime();
            }

            return(MessagesDAL.AddMessage(message));
        }
Example #15
0
        public List <AutoCompleteDTO> GetUntaggedFriends(string prefixTxt, int postID)
        {
            Member m;
            Post   p;

            MessagesDAL            member  = new MessagesDAL();
            List <Member>          members = member.SearchUntaggedMember(m = new Member(Context.Session["memberID"].ToString(), prefixTxt), p = new Post(postID));
            AutoCompleteDTO        auto;
            List <AutoCompleteDTO> items = new List <AutoCompleteDTO>();

            string[,] mmb = new string[1, 2];



            foreach (var element in members)
            {
                auto = new AutoCompleteDTO(element.MemberId, element.DisplayName);
                items.Add(auto);
            }

            return(items);
        }
Example #16
0
        public static string[] GetCompletionList(string prefixText, int count)
        {
            string encrypFriendID = null;

            if (count == 0)
            {

                count = 10;

            }

            MessagesDAL member = new MessagesDAL();
            List<Member> members = member.SearchMember(prefixText);

            List<string> items = new List<string>(count);

            foreach (var element in members)
            {
                encrypFriendID = element.MemberId;
                // items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(element.DisplayName, encrypFriendID));
            }

            return items.ToArray();
        }
Example #17
0
        public string[] AddCommentnRefresh(int postID, string commentTxt, int lastCommentID)
        {
            NewsfeedDAL newsfeedDAL = new NewsfeedDAL();
            MessagesDAL messageDAL = new MessagesDAL();
            Comments comment = new Comments();
            StringBuilder commentBuilder = new StringBuilder();

            //Decrypting the member ID
            comment.MemberId = Context.Session["memberID"].ToString();

            comment.CommentText = commentTxt;
            comment.PostId = postID;
            comment.Commentid = lastCommentID;
            messageDAL.InsertComment(comment);

            //Insert notification
            NotificationDAL notificationDAL = new NotificationDAL();

            Post aPost = new Post(postID);

            List<Member> MemberList = new List<Member>();
            MemberList = notificationDAL.GetPostOwner(aPost);
            string friendId = MemberList[0].MemberId;
            Member aFriend = new Member(friendId);

            Member aMember = new Member(Context.Session["memberID"].ToString());

            if (aMember.MemberId != aFriend.MemberId)
            {
                notificationDAL.InsertCommentedOnPostNotification(aMember, aFriend, aPost);
            }

            //Refreshing the Comment count
            Post post = new Post();
            post.PostId = comment.PostId;

            //###################################
            //refreshing Comments
            //###################################

            DataTable comments = newsfeedDAL.GetRefreshComments(post, comment);

            foreach (DataRow row in comments.Rows)
            {
                date = Convert.ToDateTime(row["CreateDate"]).ToString("M");

                //Building single message view box
                commentBuilder.Append("<div id='");
                commentBuilder.Append((row["CommentID"]).ToString());

                commentBuilder.Append("' class='aComment'><div class='deleteComment floatright'>");

                if ((row["MemberID"]).ToString() == Session["memberID"].ToString())
                {

                    commentBuilder.Append("<a class='btnDleteComment ui-icon ui-icon-close tip' title='Delete this comment'></a>");
                }
                else
                {
                    commentBuilder.Append("<a class='btnOpenMenuComment ui-icon ui-icon-circle-triangle-s tip' title='More options..'></a>");
                }

                commentBuilder.Append("</div><h5><a style='font-weight:normal;' ");
                commentBuilder.Append("id='" + (row["MemberID"]).ToString() + "'> ");

                commentBuilder.Append(row["Friend"].ToString());
                commentBuilder.Append("</a><span class='DateWithTime ui-corner-all floatright'>");

                Reusable_Methods reusable_Methods = new Reusable_Methods();
                date = reusable_Methods.FormatDateTime(Convert.ToDateTime(row["CreateDate"]));

                commentBuilder.Append(date);
                commentBuilder.Append("</span></h5><p>");
                commentBuilder.Append((row["CommentText"]).ToString());
                commentBuilder.Append("</p></div>");
                //End Building

            }
                        //Array with the       //number of commeents         //new comments
              var comentArray =  new string[] { messageDAL.CountComments(post).ToString(), commentBuilder.ToString()};

            return comentArray;
        }
Example #18
0
        public string GetAllTags(int postID)
        {
            Post p;

            StringBuilder allTags = new StringBuilder();
            MessagesDAL member = new MessagesDAL();
            List<Member> members = tagDAL.GetTagedFriends(p = new Post(postID));

            List<Member> poster = tagDAL.GetPostMemberID(p = new Post(postID));

            foreach (var element in members)
            {
                string m = Session["memberID"].ToString();

                if (poster[0].MemberId == Session["memberID"].ToString())
                {
                    allTags.Append("<li ><a id='" + element.MemberId + "' class='btnMemberProfile pointer'>" + element.DisplayName + "</a><a class='button left big floatright btnUntag ' style='margin: 0;' >Untag friend</a></li>");
                }
                else if (element.MemberId == Session["memberID"].ToString())
                {
                    allTags.Append("<li ><a id='" + element.MemberId + "' class='btnMemberProfile pointer'>" + element.DisplayName + "</a><a class='button left big floatright btnUntag ' style='margin: 0;' >Untag yourself</a></li>");
                }
                else
                {
                    allTags.Append("<li ><a id='" + element.MemberId + "' class=' btnMemberProfile pointer'>" + element.DisplayName + "</a></li>");
                }

            }

            return allTags.ToString();
        }
Example #19
0
        public string GetAllComments(int postID)
        {
            Post post = new Post();
            Comments comment = new Comments();
            MessagesDAL m = new MessagesDAL();
            string date = "";

            post.PostId = postID;
            StringBuilder comnt = new StringBuilder();
            DataTable comments = m.GetAllComments(post);

            foreach (DataRow row in comments.Rows)
            {

                Reusable_Methods reusable_Methods = new Reusable_Methods();

                date = reusable_Methods.FormatDateTime(Convert.ToDateTime(row["CreateDate"]));

                //Building single message view box
                comnt.Append("<div id='");
                comnt.Append((row["CommentID"]).ToString());
                comnt.Append("' class='aComment'><div class='deleteComment floatright'>");

                comment.Commentid = int.Parse(row["CommentID"].ToString());

                if ((row["MemberID"]).ToString() == Session["memberID"].ToString())
                {

                    comnt.Append("<a class='btnDleteComment ui-icon ui-icon-close tip floatLeft' title='Delete this comment' ></a>");
                }
                else
                {
                    //comnt.Append("<a class='btnOpenMenuComment ui-icon ui-icon-circle-triangle-s tip' title='More options..' ></a>");
                     comnt.Append("<a class='button left big floatLeft likeComment '");

                      RateAndTagDAL dal = new RateAndTagDAL();

                            string memberId = Context.Session["memberID"].ToString();
                            Member amember = new Member(memberId);

                            //Check if member not liked
                            if (dal.CommentRatingExists(amember, comment) ==0)
                            {
                                //if member not liked
                                //concatinater.Append(" homeLikeBtn");
                                comnt.Append("' title='");
                                comnt.Append("Like this comment");
                                comnt.Append("'  >");
                                comnt.Append("Like");
                            }
                            else
                            {
                                //if member is liked
                              //  concatinater.Append(" homeUnlikeBtn");
                                comnt.Append("' title='");
                                comnt.Append("Unlike this comment");
                                comnt.Append("'  >");
                                comnt.Append("Unlike");
                            }

                            comnt.Append("</a>");

                     comnt.Append("<a class='button right big floatLeft reportComment' title='Report this comment'>Report </a>");
                }

                comnt.Append("</div><h5><a style='font-weight:normal;' ");
                comnt.Append("id='" + (row["MemberID"]).ToString() + "'> ");
                comnt.Append(row["Friend"].ToString());
                comnt.Append("</a><span class='DateWithTime ui-corner-all floatright'>");
                comnt.Append(date);
                comnt.Append("</span></h5><p>");
                comnt.Append((row["CommentText"]).ToString());
                comnt.Append("</p></div>");
                //End Building

            }

            return comnt.ToString();
            //End Refresh
        }
Example #20
0
        //  Messages message;
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Get the Next/Previous Message
            //if (!String.IsNullOrEmpty(Request.Form["msgeID"].ToString()) && !String.IsNullOrEmpty(Request.Form["con"].ToString()))
            //{
            //    StringBuilder concatinater = new StringBuilder();
            //    string date = "";
            //    string con = Request.Form["con"].ToString();

            //    int i = int.Parse(Request.Form["msgeID"].ToString());
            //    {

            //    if(i == 272)
            //        Response.Write("<div class='LoginUserValidationSummary BorberRad3'>Error. Your message was not sent.</div>");

            //    }
            //    //   message.MessageId = id;
            //    Messages message = new Messages();
            //    message.MessageId = int.Parse(Request.Form["msgeID"].ToString());

            //    DataTable aMessage = test.GetNxtPreMessage(message, con);

            //    foreach (DataRow row in aMessage.Rows)
            //    {
            //        date = Convert.ToDateTime(row["DateTime"]).ToString("D");

            //        //Building single message view box
            //        concatinater.Append("<div class='SingleViewmsgeWrapper' id='");
            //        concatinater.Append(row["messageID"].ToString());
            //        concatinater.Append("'><div class='msgeHeading' ><h2> <a href='#' class=' '>");
            //        concatinater.Append(row["Friend"].ToString());
            //        concatinater.Append("</a><span class='DateWithTime floatright'>");
            //        concatinater.Append(date);
            //        concatinater.Append("</span></ h2> </div>");
            //        concatinater.Append("<p class='width100%'>");
            //        concatinater.Append(row["MessageText"].ToString());
            //        concatinater.Append("</p></div>");

            //    }
            //    Response.Write(concatinater.ToString());
            //}
            #endregion

            #region Delete a Message

            if (Request.Form["msgeID"] != null)
            {

                Messages message = new Messages(int.Parse(Request.Form["msgeID"].ToString()));
                MessagesDAL test = new MessagesDAL();
                test.DeleteMessage(message);
                Response.Write("<div class='msgeSentNotification blueFontTextColor BorberRad3'>Your message was deleted successfully.</div>");

            }
            #endregion

            #region Get Friend Profile
            if (Request.Form["encrypMemberID"] != null)
            {

                string frnd = Request.Form["encrypMemberID"].ToString();
                Member friend = new Member(frnd);
                Response.Write(Request.Form["encrypMemberID"].ToString());
                Response.Redirect("~/Profile.aspx");

            }

            #endregion

            //Changed to webmethod
            #region Insert A Comment
            if (Request.Form["ID"] != null && Request.Form["pstTxt"] != null)
            {

               MessagesDAL m = new MessagesDAL();
               Comments comment = new Comments();
               comment.MemberId = Session["memberID"].ToString();
               comment.CommentText = Request.Form["pstTxt"].ToString();
               comment.PostId = int.Parse(Request.Form["ID"].ToString());
               m.InsertComment(comment);

                //Refreshing the Comment count
                Post post = new Post();
                post.PostId = comment.PostId;

              //  Response.Write(m.CountComments(post));

                var comentArray = new string[] { m.CountComments(post).ToString(), };

                //JavaScriptSerializer serializer = new JavaScriptSerializer();
                //Response.Write(serializer.Serialize(loc));
                //.Response.ContentType = "application/json";
                //End Refresh
            }
            #endregion

            #region get all Comments
            if (Request.Form["ID"] != null && Request.Form["pstTxt"] == null)
            {

                Post post = new Post();
                Comments comment = new Comments();
                MessagesDAL m = new MessagesDAL();
                string date = "";

                post.PostId = int.Parse(Request.Form["ID"].ToString());

                StringBuilder comnt = new StringBuilder();
                DataTable comments = m.GetAllComments(post);

                foreach (DataRow row in comments.Rows)
                {
                    date = Convert.ToDateTime(row["CreateDate"]).ToString("D");

                    //Building single message view box
                    comnt.Append("<div id='");
                    comnt.Append((row["CommentID"]).ToString());
                    comnt.Append("' class='aComment'><div class='deleteComment floatright'><a class='btnDleteComment'>X</a></div><h5><a style='font-weight:normal;' ");
                    comnt.Append("id='" + (row["MemberID"]).ToString() + "'> ");
                    //comnt.Append("' href='#'> ");
                    comnt.Append(row["Friend"].ToString());
                    comnt.Append("</a><span class='DateWithTime ui-corner-all floatright'>");
                    comnt.Append(date);
                    comnt.Append("</span></h5><p>");
                    comnt.Append((row["CommentText"]).ToString());
                    comnt.Append("</p></div>");

                }

                Response.Write(comnt.ToString());
                //End Refresh
            }
            #endregion
        }
Example #21
0
        public string[] GetNxtPre(int messageID, string condition)
        {
            MessagesDAL test = new MessagesDAL();
            Member member = new Member();
            member.MemberId = Context.Session["memberID"].ToString();
            m.MemberId = Session["memberID"].ToString();
            inbox = test.getInboxList(m);

            Messages message = new Messages();

            message.MessageId = messageID;
            int[] index = test.GetMessageIndex(message, member);
            //int[] index = { 0, 0 };

            if (condition == "pre")
            {

                inbox = test.GetPreviousMessage(message, member);
            }
            else
            {
                inbox = test.GetNextMessage(message, member);
            }

            string concatinater = BuildSingleMessage(inbox);

            if (concatinater == "")
            {
                Message msg = new Message(messageID);

                inbox = test.GetAMessage(msg);
                concatinater = BuildSingleMessage(inbox);

            }

            string[] singleView = new string[] { index[0].ToString(), index[1].ToString(), concatinater };

            return singleView;
        }
Example #22
0
        public List<AutoCompleteDTO> GetUntaggedFriends(string prefixTxt, int postID)
        {
            Member m;
            Post p;

            MessagesDAL member = new MessagesDAL();
            List<Member> members = member.SearchUntaggedMember(m = new Member(Context.Session["memberID"].ToString(), prefixTxt), p = new Post(postID));
            AutoCompleteDTO auto;
            List<AutoCompleteDTO> items = new List<AutoCompleteDTO>();
            string[,] mmb = new string[1, 2];

            foreach (var element in members)
            {

                auto = new AutoCompleteDTO(element.MemberId, element.DisplayName);
                items.Add(auto);

            }

            return items;
        }
Example #23
0
        //  Messages message;
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Get the Next/Previous Message
            //if (!String.IsNullOrEmpty(Request.Form["msgeID"].ToString()) && !String.IsNullOrEmpty(Request.Form["con"].ToString()))
            //{
            //    StringBuilder concatinater = new StringBuilder();
            //    string date = "";
            //    string con = Request.Form["con"].ToString();

            //    int i = int.Parse(Request.Form["msgeID"].ToString());
            //    {

            //    if(i == 272)
            //        Response.Write("<div class='LoginUserValidationSummary BorberRad3'>Error. Your message was not sent.</div>");

            //    }
            //    //   message.MessageId = id;
            //    Messages message = new Messages();
            //    message.MessageId = int.Parse(Request.Form["msgeID"].ToString());

            //    DataTable aMessage = test.GetNxtPreMessage(message, con);

            //    foreach (DataRow row in aMessage.Rows)
            //    {
            //        date = Convert.ToDateTime(row["DateTime"]).ToString("D");

            //        //Building single message view box
            //        concatinater.Append("<div class='SingleViewmsgeWrapper' id='");
            //        concatinater.Append(row["messageID"].ToString());
            //        concatinater.Append("'><div class='msgeHeading' ><h2> <a href='#' class=' '>");
            //        concatinater.Append(row["Friend"].ToString());
            //        concatinater.Append("</a><span class='DateWithTime floatright'>");
            //        concatinater.Append(date);
            //        concatinater.Append("</span></ h2> </div>");
            //        concatinater.Append("<p class='width100%'>");
            //        concatinater.Append(row["MessageText"].ToString());
            //        concatinater.Append("</p></div>");


            //    }
            //    Response.Write(concatinater.ToString());
            //}
            #endregion


            #region Delete a Message

            if (Request.Form["msgeID"] != null)
            {
                Messages    message = new Messages(int.Parse(Request.Form["msgeID"].ToString()));
                MessagesDAL test    = new MessagesDAL();
                test.DeleteMessage(message);
                Response.Write("<div class='msgeSentNotification blueFontTextColor BorberRad3'>Your message was deleted successfully.</div>");
            }
            #endregion


            #region Get Friend Profile
            if (Request.Form["encrypMemberID"] != null)
            {
                string frnd   = Request.Form["encrypMemberID"].ToString();
                Member friend = new Member(frnd);
                Response.Write(Request.Form["encrypMemberID"].ToString());
                Response.Redirect("~/Profile.aspx");
            }


            #endregion

            //Changed to webmethod
            #region Insert A Comment
            if (Request.Form["ID"] != null && Request.Form["pstTxt"] != null)
            {
                MessagesDAL m       = new MessagesDAL();
                Comments    comment = new Comments();
                comment.MemberId    = Session["memberID"].ToString();
                comment.CommentText = Request.Form["pstTxt"].ToString();
                comment.PostId      = int.Parse(Request.Form["ID"].ToString());
                m.InsertComment(comment);

                //Refreshing the Comment count
                Post post = new Post();
                post.PostId = comment.PostId;

                //  Response.Write(m.CountComments(post));

                var comentArray = new string[] { m.CountComments(post).ToString(), };

                //JavaScriptSerializer serializer = new JavaScriptSerializer();
                //Response.Write(serializer.Serialize(loc));
                //.Response.ContentType = "application/json";
                //End Refresh
            }
            #endregion


            #region get all Comments
            if (Request.Form["ID"] != null && Request.Form["pstTxt"] == null)
            {
                Post        post    = new Post();
                Comments    comment = new Comments();
                MessagesDAL m       = new MessagesDAL();
                string      date    = "";

                post.PostId = int.Parse(Request.Form["ID"].ToString());


                StringBuilder comnt    = new StringBuilder();
                DataTable     comments = m.GetAllComments(post);

                foreach (DataRow row in comments.Rows)
                {
                    date = Convert.ToDateTime(row["CreateDate"]).ToString("D");

                    //Building single message view box
                    comnt.Append("<div id='");
                    comnt.Append((row["CommentID"]).ToString());
                    comnt.Append("' class='aComment'><div class='deleteComment floatright'><a class='btnDleteComment'>X</a></div><h5><a style='font-weight:normal;' ");
                    comnt.Append("id='" + (row["MemberID"]).ToString() + "'> ");
                    //comnt.Append("' href='#'> ");
                    comnt.Append(row["Friend"].ToString());
                    comnt.Append("</a><span class='DateWithTime ui-corner-all floatright'>");
                    comnt.Append(date);
                    comnt.Append("</span></h5><p>");
                    comnt.Append((row["CommentText"]).ToString());
                    comnt.Append("</p></div>");
                }

                Response.Write(comnt.ToString());
                //End Refresh
            }
            #endregion
        }
Example #24
0
        public static bool ReviewContract(int offerId, bool isAccept, bool isByAdCreator)
        {
            if (!MessagesDAL.MarkContractAsReviewed(offerId))
            {
                return(false);
            }
            var offer = OffersDAL.GetOffer(offerId);

            if (offer == null)
            {
                return(false);
            }
            var ad = AdsDAL.GetAd(offer.AdId);

            if (ad == null)
            {
                return(false);
            }
            var sender = SM.GetPersonalAreaUser();

            if (offer.SenderId != sender.Id && ad.SenderId != sender.Id)
            {
                return(false);
            }
            if (isAccept)
            {
                AdsDAL.ChangeAdStatusToFinishedAndActiveUntilDateToNow(offer.AdId);
                OffersDAL.ChangeOfferContractStatus(offer.Id, (int)ContractStatuses.Accepted);
                OffersDAL.UpdateOfferContractSendDate(offer.Id, DateTime.Now.ToUniversalTime());
                //var notificationsUserId = User.SystemNotificationsUserId;
                var messageText = "Контракт c " + sender.CompanyNameWithTypeOfOwnership + " по объявлению " + ad.Name + " подтвержден.";
                var message     = new Message
                {
                    SenderId    = offer.SenderId,
                    RecipientId = ad.SenderId,
                    Text        = messageText,
                    AdId        = ad.Id,
                    OfferId     = offer.Id
                };
                AddMessage(message);
                var offers = OffersDAL.GetOffers(ad.Id).Where(o => o.ContractStatus != ContractStatuses.Accepted).ToList();
                if (offers.Any())
                {
                    var adSender = UsersDAL.GetUser(ad.SenderId);
                    if (adSender != null)
                    {
                        adSender.Town = TownsDAL.GetTown(adSender.CityId);
                        var notificationsUserId = MContract.Models.User.SystemNotificationsUserId;
                        foreach (var o in offers)
                        {
                            messageText = "По объявлению " + ad.Name + " организатора " + adSender.CompanyNameWithTypeOfOwnership + (adSender.Town != null ? ", " + adSender.TownName : "") +
                                          " заключен контракт с другим участником.";
                            message = new Message
                            {
                                SenderId    = notificationsUserId,
                                RecipientId = o.SenderId,
                                Text        = messageText,
                                AdId        = ad.Id
                            };
                            AddMessage(message);
                        }
                    }
                }
            }
            else
            {
                //удаляем предложение, только если отменяет контракт участник, подавший это предложение, а не организатор
                //если отменяет контракт организатор
                if (isByAdCreator)
                {
                    OffersDAL.ChangeOfferContractStatus(offer.Id, (int)ContractStatuses.Declined);
                }
                else                //а если контракт отменяет участник, подавший предложение
                {
                    OffersDAL.DeleteOffer(offerId);
                }

                //var notificationsUserId = User.SystemNotificationsUserId;
                var messageText = "Контракт c " + sender.CompanyNameWithTypeOfOwnership + " по объявлению " + ad.Name + " отменен.";
                var message     = new Message
                {
                    SenderId    = offer.SenderId,
                    RecipientId = ad.SenderId,
                    Text        = messageText,
                    AdId        = ad.Id,
                    OfferId     = offer.Id
                };
                AddMessage(message);
            }
            return(true);
        }
Example #25
0
        public string[] AddCommentnRefresh(int postID, string commentTxt, int lastCommentID)
        {
            NewsfeedDAL   newsfeedDAL    = new NewsfeedDAL();
            MessagesDAL   messageDAL     = new MessagesDAL();
            Comments      comment        = new Comments();
            StringBuilder commentBuilder = new StringBuilder();


            //Decrypting the member ID
            comment.MemberId = Context.Session["memberID"].ToString();

            comment.CommentText = commentTxt;
            comment.PostId      = postID;
            comment.Commentid   = lastCommentID;
            messageDAL.InsertComment(comment);

            //Insert notification
            NotificationDAL notificationDAL = new NotificationDAL();

            Post aPost = new Post(postID);

            List <Member> MemberList = new List <Member>();

            MemberList = notificationDAL.GetPostOwner(aPost);
            string friendId = MemberList[0].MemberId;
            Member aFriend  = new Member(friendId);

            Member aMember = new Member(Context.Session["memberID"].ToString());

            if (aMember.MemberId != aFriend.MemberId)
            {
                notificationDAL.InsertCommentedOnPostNotification(aMember, aFriend, aPost);
            }

            //Refreshing the Comment count
            Post post = new Post();

            post.PostId = comment.PostId;


            //###################################
            //refreshing Comments
            //###################################

            DataTable comments = newsfeedDAL.GetRefreshComments(post, comment);

            foreach (DataRow row in comments.Rows)
            {
                date = Convert.ToDateTime(row["CreateDate"]).ToString("M");

                //Building single message view box
                commentBuilder.Append("<div id='");
                commentBuilder.Append((row["CommentID"]).ToString());

                commentBuilder.Append("' class='aComment'><div class='deleteComment floatright'>");



                if ((row["MemberID"]).ToString() == Session["memberID"].ToString())
                {
                    commentBuilder.Append("<a class='btnDleteComment ui-icon ui-icon-close tip' title='Delete this comment'></a>");
                }
                else
                {
                    commentBuilder.Append("<a class='btnOpenMenuComment ui-icon ui-icon-circle-triangle-s tip' title='More options..'></a>");
                }

                commentBuilder.Append("</div><h5><a style='font-weight:normal;' ");
                commentBuilder.Append("id='" + (row["MemberID"]).ToString() + "'> ");



                commentBuilder.Append(row["Friend"].ToString());
                commentBuilder.Append("</a><span class='DateWithTime ui-corner-all floatright'>");

                Reusable_Methods reusable_Methods = new Reusable_Methods();
                date = reusable_Methods.FormatDateTime(Convert.ToDateTime(row["CreateDate"]));

                commentBuilder.Append(date);
                commentBuilder.Append("</span></h5><p>");
                commentBuilder.Append((row["CommentText"]).ToString());
                commentBuilder.Append("</p></div>");
                //End Building
            }
            //Array with the       //number of commeents         //new comments
            var comentArray = new string[] { messageDAL.CountComments(post).ToString(), commentBuilder.ToString() };

            return(comentArray);
        }
Example #26
0
        public string GetAllComments(int postID)
        {
            Post        post    = new Post();
            Comments    comment = new Comments();
            MessagesDAL m       = new MessagesDAL();
            string      date    = "";

            post.PostId = postID;
            StringBuilder comnt    = new StringBuilder();
            DataTable     comments = m.GetAllComments(post);

            foreach (DataRow row in comments.Rows)
            {
                Reusable_Methods reusable_Methods = new Reusable_Methods();

                date = reusable_Methods.FormatDateTime(Convert.ToDateTime(row["CreateDate"]));

                //Building single message view box
                comnt.Append("<div id='");
                comnt.Append((row["CommentID"]).ToString());
                comnt.Append("' class='aComment'><div class='deleteComment floatright'>");

                comment.Commentid = int.Parse(row["CommentID"].ToString());

                if ((row["MemberID"]).ToString() == Session["memberID"].ToString())
                {
                    comnt.Append("<a class='btnDleteComment ui-icon ui-icon-close tip floatLeft' title='Delete this comment' ></a>");
                }
                else
                {
                    //comnt.Append("<a class='btnOpenMenuComment ui-icon ui-icon-circle-triangle-s tip' title='More options..' ></a>");
                    comnt.Append("<a class='button left big floatLeft likeComment '");

                    RateAndTagDAL dal = new RateAndTagDAL();

                    string memberId = Context.Session["memberID"].ToString();
                    Member amember  = new Member(memberId);

                    //Check if member not liked
                    if (dal.CommentRatingExists(amember, comment) == 0)
                    {
                        //if member not liked
                        //concatinater.Append(" homeLikeBtn");
                        comnt.Append("' title='");
                        comnt.Append("Like this comment");
                        comnt.Append("'  >");
                        comnt.Append("Like");
                    }
                    else
                    {
                        //if member is liked
                        //  concatinater.Append(" homeUnlikeBtn");
                        comnt.Append("' title='");
                        comnt.Append("Unlike this comment");
                        comnt.Append("'  >");
                        comnt.Append("Unlike");
                    }

                    comnt.Append("</a>");

                    comnt.Append("<a class='button right big floatLeft reportComment' title='Report this comment'>Report </a>");
                }

                comnt.Append("</div><h5><a style='font-weight:normal;' ");
                comnt.Append("id='" + (row["MemberID"]).ToString() + "'> ");
                comnt.Append(row["Friend"].ToString());
                comnt.Append("</a><span class='DateWithTime ui-corner-all floatright'>");
                comnt.Append(date);
                comnt.Append("</span></h5><p>");
                comnt.Append((row["CommentText"]).ToString());
                comnt.Append("</p></div>");
                //End Building
            }

            return(comnt.ToString());
            //End Refresh
        }