예제 #1
0
        /// <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);
        }