/// <summary> /// Map entity to dto /// </summary> /// <param name="entity">Object to extension</param> /// <param name="addAuthors">Indicate if add authors data in dto</param> public static ScopeDto Map(this Scope entity, bool addAuthors) { if (entity == null) { return(null); } ScopeDto dto = new ScopeDto(); if (entity.Valid) { dto.Id = entity.Id; if (addAuthors) { AuthorMap.Map(dto, entity); } } else { dto.AddNotifications(entity.Notifications); } dto.Name = entity.Name; dto.AccessKey = entity.AccessKey; dto.AllowLogin = entity.AllowLogin; dto.IsActive = entity.IsActive; return(dto); }
/// <summary> /// Map entity to dto /// </summary> /// <param name="entity">Object to extension</param> /// <param name="addAuthors">Indicate if add authors data in dto</param> public static RoleDto Map(this Role entity, bool addAuthors) { if (entity == null) { return(null); } RoleDto dto = new RoleDto(); if (entity.Valid) { dto.Id = entity.Id; if (addAuthors) { AuthorMap.Map(dto, entity); } } else { dto.AddNotifications(entity.Notifications); } dto.Name = entity.Name; dto.Description = entity.Description; dto.Scope = new SimpleIdentification <Guid>(entity.Scope?.Id, entity.Scope?.Name); dto.IsActive = entity.IsActive; return(dto); }
/// <summary> /// Map entity to dto /// </summary> /// <param name="entity">Object to extension</param> /// <param name="addAuthors">Indicate if add authors data in dto</param> /// <param name="useLazy">Indicate if load related data in dto</param> public static UserDto Map(this User entity, bool addAuthors, bool useLazy) { if (entity == null) { return(null); } UserDto dto = new UserDto(); if (entity.Valid) { dto.Id = entity.Id; if (addAuthors) { AuthorMap.Map(dto, entity); } } else { dto.AddNotifications(entity.Notifications); } dto.Document = entity.Document; dto.Name = entity.Name; dto.BornDate = entity.BornDate; dto.Email = entity.Email.Address; dto.IsActive = entity.IsActive; dto.Type = entity.Type; if (useLazy) { LoadLazy(entity, dto); } return(dto); }