Esempio n. 1
0
        //DTO to domain object
        public override Item ToDomainObject(Node parent)
        {
            var newNode = new Node()
            {
                Key     = this.Key,
                Parent  = parent,
                Note    = this.Note,
                Deleted = this.Deleted,
                Notes   = DtoNote.DtoNoteListToDomainObjecs(this.Notes),
                //CreatedOn = DateTime.Parse(this.CreatedOn, null, System.Globalization.DateTimeStyles.RoundtripKind),
                //UpdatedOn = DateTime.Parse(this.UpdatedOn, null, System.Globalization.DateTimeStyles.RoundtripKind)
            };

            return(newNode);
        }
Esempio n. 2
0
 //Object to DTO
 public override DtoItem ToDto()
 {
     return(new DtoNode()
     {
         Id = this.Id,
         Key = this.Key,
         Type = "node",
         Parent = this.Parent == null ? (int?)null : this.Parent.Id,
         Deleted = this.Deleted,
         Note = this.Note,
         Labels = this.Labels.Select(label => label.ToDto()).ToList(),
         Notes = DtoNote.NoteListToDtos(this.Notes),
         LeafChildren = this.Children.Where(n => n is Leaf).Select(n => (DtoLeaf)n.ToDto()).ToList(),
         NodeChildren = this.Children.Where(n => n is Node).Select(n => n.ToDtoReduced()).ToList(),
         CreatedOn = this.CreatedOn.ToString("s", System.Globalization.CultureInfo.InvariantCulture),
         UpdatedOn = this.UpdatedOn.ToString("s", System.Globalization.CultureInfo.InvariantCulture),
         Path = this.Path()
     });
 }
Esempio n. 3
0
        //Dto to domain object
        public override Item ToDomainObject(Node parent)
        {
            var newLeaf = new Leaf()
            {
                Key     = this.Key,
                Parent  = parent,
                Deleted = this.Deleted,
                Value   = this.Value,
                Notes   = DtoNote.DtoNoteListToDomainObjecs(this.Notes),
                Stale   = this.Stale,
                //CreatedOn = DateTime.Parse(this.CreatedOn, null, System.Globalization.DateTimeStyles.RoundtripKind),
                //UpdatedOn = DateTime.Parse(this.UpdatedOn, null, System.Globalization.DateTimeStyles.RoundtripKind)
            };

            if (parent == null)
            {
                throw new InvalidDataException("Leaf must have a parent."); // TODO: Throw 4XX rather than 5XX
            }

            return(newLeaf);
        }
Esempio n. 4
0
 //Object to DTO
 public override DtoItem ToDto()
 {
     if (this.Parent == null)
     {
         throw new NullReferenceException("Leaf's parent cannot be null.");
     }
     return(new DtoLeaf()
     {
         Id = this.Id,
         Key = this.Key,
         Type = "leaf",
         Parent = this.Parent.Id,
         Deleted = this.Deleted,
         Labels = this.Labels.Select(label => label.ToDto()).ToList(),
         Notes = DtoNote.NoteListToDtos(this.Notes),
         Value = this.Value,
         Stale = this.Stale,
         CreatedOn = this.CreatedOn.ToString("s", System.Globalization.CultureInfo.InvariantCulture),
         UpdatedOn = this.UpdatedOn.ToString("s", System.Globalization.CultureInfo.InvariantCulture),
         Path = this.Path(),
     });
 }