Esempio n. 1
0
        public static IUserGroup BuildEntity(UserGroupDto dto)
        {
            var userGroup = new UserGroup(dto.UserCount, dto.Alias, dto.Name,
                                          dto.DefaultPermissions.IsNullOrWhiteSpace()
                    ? Enumerable.Empty <string>()
                    : dto.DefaultPermissions.ToCharArray().Select(x => x.ToString(CultureInfo.InvariantCulture)).ToList(),
                                          dto.Icon);

            try
            {
                userGroup.DisableChangeTracking();
                userGroup.Id             = dto.Id;
                userGroup.CreateDate     = dto.CreateDate;
                userGroup.UpdateDate     = dto.UpdateDate;
                userGroup.StartContentId = dto.StartContentId;
                userGroup.StartMediaId   = dto.StartMediaId;
                if (dto.UserGroup2AppDtos != null)
                {
                    foreach (var app in dto.UserGroup2AppDtos)
                    {
                        userGroup.AddAllowedSection(app.AppAlias);
                    }
                }

                userGroup.ResetDirtyProperties(false);
                return(userGroup);
            }
            finally
            {
                userGroup.EnableChangeTracking();
            }
        }