Пример #1
0
 public static string GetMessageText(Message message, bool showUserName = false)
 {
     if (showUserName)
     {
         return string.Format("{0} - {1} {2}", Users.GetUser(message.UserId).Name, message.MessageText, TimeAgo(DateTime.Now, message.MessageTime));
     }
     else
     {
         return string.Format("{0} {1}", message.MessageText, TimeAgo(DateTime.Now, message.MessageTime));
     }
 }
Пример #2
0
 public static Message Create(string userName, string message)
 {
     Message newMessage = new Message
     {
         Id = Messages.NewId,
         MessageText = message,
         MessageTime = DateTime.Now,
         UserId = Users.Create(userName).Id
     };
     ApplicationData.Messages.Add(newMessage);
     return newMessage;
 }