Example #1
0
        /// <summary>
        /// Converts this instance of <see cref="IdentityRole"/> to an instance of <see cref="RoleDto"/>.
        /// </summary>
        /// <param name="entity"><see cref="IdentityRole"/> to convert.</param>
        public static RoleDto ToDTO(this IdentityRole entity, bool includeUsers = false)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new RoleDto();

            dto.id               = entity.Id;
            dto.name             = entity.Name;
            dto.concurrencyStamp = entity.ConcurrencyStamp;
            dto.normalizedName   = entity.NormalizedName;
            if (includeUsers)
            {
                //dto.postCount = entity.Posts.Where(p => p.IsPublished == 1).Count();
            }

            entity.OnDTO(dto);

            return(dto);
        }