summaryrefslogtreecommitdiff
path: root/Juick/ViewModels/PostItem.cs
blob: a1b4ec5c4075afa834e84040559edc619a8e93e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Net;
using JuickApi;
using Juick.Classes;
using System.Globalization;

namespace Juick.ViewModels
{
    public class PostItem
    {
        public PostItem(Message message)
        {
            MID = message.Mid;
            RID = message.Rid;
            Username = message.User.UName;
            // Juick timestamp in utc: 2013-04-22 13:14:30
            var timestamp = DateTime.ParseExact(message.Timestamp, "yyyy-MM-dd HH:mm:ss", null);
            Status = string.Format("{0}", DateHelper.PrettyDate(timestamp.ToLocalTime()));
            if (message.Replies > 0)
                Status = string.Format("{0}, replies: {1}", Status, message.Replies);
            MessageText = HttpUtility.HtmlDecode(message.Body);

            UserfeedUri = new Uri(string.Format("/UserFeed.xaml?uid={0}", message.User.Uid), UriKind.Relative);
            if (message.Tags != null)
            {
                MessageText = string.Join(", ", message.Tags) + Environment.NewLine + MessageText;
            }
            AvatarUri = new Uri(string.Format("http://i.juick.com/as/{0}.png", message.User.Uid), UriKind.Absolute);
            if (message.Photo != null)
            {
                Attachment = new Uri(message.Photo.Small, UriKind.Absolute);
            }
        }
       
        public int MID {get;set;}
        
        public int RID {get;set;}
        
        public string Username {get;set;}
        
        public Uri AvatarUri {get;set;}
        
        public Uri UserfeedUri { get; set; }
        
        public Uri Attachment {get;set;}

        public string Status {get;set;}

        public string MessageText { get; set; }
                
    }
}