Exemple #1
0
        public static Todo ParseJson(JToken json)
        {
            Todo todo = new Todo();
            string id = Json.TryGetJsonProperty(json, "id");

            string created = Json.TryGetJsonProperty(json, "createdAt");
            if (created != null)
            {
                DateTime dtc = UnixDate.ToDateTime(created);
                //t.CreatedDateTime = dtc;
                todo.Created = Checkin.GetDateString(dtc);
            }

            var tipJson = json["tip"];
            if (tipJson != null)
            {
                var tip = Tip.ParseJson(tipJson);
                if (tip != null)
                {
                    if (todo.Created != null)
                    {
                        tip.OverrideAddedText = "added " + todo.Created + (
                            tip.User != null ? (" (via " + tip.User.ToString() + ")") : string.Empty);
                    }

                    todo.Tip = tip;
                }
            }

            todo.TodoId = id;

            return todo;
        }