/// <summary> /// One media from json /// </summary> public IMedia MapJsonToMedia(string json) { IMedia m = new Models.Media(); JObject jObject = JObject.Parse(json); JToken jMedia = jObject["data"]; m.CreatedBy = userJson.MapJsonToMinifiedUser(jMedia["user"]); m.ImageThumbnailUrl = jMedia["images"]["thumbnail"]["url"].ToString(); m.ImageLowResolutionUrl = jMedia["images"]["low_resolution"]["url"].ToString(); m.ImageStandardResolutionUrl = jMedia["images"]["standard_resolution"]["url"].ToString(); m.Id = jMedia["id"].ToString(); m.Text = jMedia["caption"]["text"].ToString(); m.CreatedTimeUnixMiliseconds = long.Parse(jMedia["caption"]["created_time"].ToString()) * 1000; m.LikesCount = int.Parse(jMedia["likes"]["count"].ToString()); m.Tags = new List <string>(); foreach (var token in jMedia["tags"]) { m.Tags.Add(token.ToString()); } m.CommentsCount = int.Parse(jMedia["comments"]["count"].ToString()); m.MediaUrl = jMedia["link"].ToString(); m.Location = new JsonLocationController().MapJsonToLocation(jMedia["location"]); m.UsersInPhoto = new List <IMinifiedUser>(); foreach (var token in jMedia["users_in_photo"].Children()) { m.UsersInPhoto.Add(userJson.MapJsonToMinifiedUser(token["user"])); } return(m); }
public Models.IComment MapJsonToComment(JToken jComment) { return(new Models.Comment() { Id = long.Parse(jComment["id"].ToString()), Text = jComment["text"].ToString(), From = jsonUserController.MapJsonToMinifiedUser(jComment["from"]), CreatedTimeUnixMiliseconds = long.Parse(jComment["created_time"].ToString()) * 1000, }); }