示例#1
0
 public Models.Entity Map(Lib.Models.Entity entity)
 {
     if (entity == null)
     {
         return(null);
     }
     return(new Models.Entity()
     {
         Id = entity.Id,
         Name = entity.Name,
         PermissionsId = (entity.Permissions?.Id != null)? (int)entity.Permissions?.Id:0,
         Permissions = (entity.Permissions?.Id == 0)? Map(entity.Permissions) : null,
         Details = Map(entity.Details).Concat(Map(entity.Properties)).ToList(),
         EntityGroups = Map <Models.Entity>(entity.Groups)
     });
 }
示例#2
0
        public Lib.Models.Entity Map(Models.Entity entity)
        {
            if (entity == null)
            {
                return(null);
            }
            var ent = new Lib.Models.Entity()
            {
                Id          = entity.Id,
                Name        = entity.Name,
                Permissions = Map(entity.Permissions)
            };

            if (entity.Details != null)
            {
                ent.Details    = new List <Lib.Models.Detail>();
                ent.Properties = new List <Lib.Models.Property>();
                foreach (var detail in entity.Details)
                {
                    if (detail.Name != null)
                    {
                        var test = new Lib.Models.Property()
                        {
                            Name   = detail.Name,
                            Detail = Map(detail)
                        };
                        ent.Properties = ent.Properties.Append(test);
                    }
                    else
                    {
                        ent.Details = ent.Details.Append(Map(detail));
                    }
                }
            }

            return(ent);
        }