Exemplo n.º 1
0
        public UserForApiContract(User user, string fallbackName, IUserIconFactory iconFactory, UserOptionalFields optionalFields)
            : base(user, fallbackName)
        {
            if (user == null)
            {
                return;
            }

            Active         = user.Active;
            GroupId        = user.GroupId;
            MemberSince    = user.CreateDate;
            VerifiedArtist = user.VerifiedArtist;

            if (optionalFields.HasFlag(UserOptionalFields.KnownLanguages))
            {
                KnownLanguages = user.KnownLanguages.Select(l => new UserKnownLanguageContract(l)).ToArray();
            }

            if (optionalFields.HasFlag(UserOptionalFields.MainPicture) && !string.IsNullOrEmpty(user.Email) && iconFactory != null)
            {
                MainPicture = iconFactory.GetIcons(user, ImageSizes.All);
            }

            if (optionalFields.HasFlag(UserOptionalFields.OldUsernames))
            {
                OldUsernames = user.OldUsernames.Select(n => new OldUsernameContract(n)).ToArray();
            }
        }
Exemplo n.º 2
0
        public UserForApiContract(User user, IUserIconFactory iconFactory, UserOptionalFields optionalFields)
            : base(user)
        {
            Active      = user.Active;
            GroupId     = user.GroupId;
            MemberSince = user.CreateDate;

            if (optionalFields.HasFlag(UserOptionalFields.MainPicture) && !string.IsNullOrEmpty(user.Email))
            {
                var thumbUrl = iconFactory.GetIconUrl(user);

                MainPicture = new EntryThumbForApiContract {
                    UrlThumb = thumbUrl,
                };
            }
        }