public static StatusViewModel MapToViewStatus(BlipFace.Service.Entities.BlipStatus status)
{
StatusViewModel st = new StatusViewModel();
try
{
//todo: trzeba uważać bo gdy nie ma recipient to
//rzuca wyjątekiem nullreference
string reciptientAvatar = string.Empty;
string reciptientLogin = string.Empty;
//czasami data nie jest ustawiana przez Blipa - dziwne
string creationDate = string.Empty;
string avatarUrl = status.User.Avatar == null
? "http://static1.blip.pl/images/nn_nano.png?1240395130"
: status.User.Avatar.Url50;
string pictureUrl = string.Empty;
if (status.Pictures != null && status.Pictures.Count > 0)
{
pictureUrl = status.Pictures[0].Url;
}
st.StatusId = status.Id;
st.UserId = status.User.Id;
st.Content = status.Content;
st.UserAvatar50 = avatarUrl;
st.RecipientAvatar50 = reciptientAvatar;
st.RecipientLogin = reciptientLogin;
st.CreationDate = creationDate;
st.UserLogin = status.User.Login;
st.StatusType = status.Type;
st.FirstPictureUrl = pictureUrl;
}
catch (Exception e)
{
throw;
}
return st;
}