예제 #1
0
        public static IEnumerable <WidgetClassifiedMessage> GetWidgetClassifiedMessages(string classifiedId, string userId)
        {
            var messages = new List <WidgetClassifiedMessage>();

            Dictionary <string, object> infoParameters = new Dictionary <string, object>();

            infoParameters.Add("classifiedId", classifiedId);

            DataTable msgData = DBConn.ExecuteCommand("sp_Widgets_Messages_FromClassified", infoParameters).Tables[0];

            if (msgData.Rows.Count > 0)
            {
                foreach (DataRow row in msgData.Rows)
                {
                    var msgFrom = row["From"].ToString();

                    var message = new WidgetClassifiedMessage
                    {
                        ClassifiedId = row["ClassifiedId"].ToString(),
                        Id           = (int)row["Id"],
                        ResponseTo   = (int)row["ReplyTo"],
                        Message      = row["Message"].ToString(),
                        Date         = (DateTime)row["Date"],
                        MessageFrom  = (msgFrom == userId ? "You" : UserDetailsService.RetFullName(msgFrom)),
                        IsOwner      = msgFrom == userId
                    };

                    if (message.ResponseTo == 0)
                    {
                        messages.Add(message);
                    }
                    else
                    {
                        var msgFound = messages.Find(m => m.Id == message.ResponseTo);
                        if (msgFound == null)
                        {
                            messages.Add(message);
                        }
                        else
                        {
                            msgFound.Responses.Add(message);
                        }
                    }
                }
            }

            return(messages);
        }
예제 #2
0
 public void AddMessage(WidgetClassifiedMessage message)
 {
     message.IncDepth();
     this.Responses.ToList().Add(message);
 }