Exemple #1
0
        /// <summary>
        ///     To the azure model.
        /// </summary>
        /// <param name="userIdentity">The user identity.</param>
        /// <returns>UserIdentityAzure.</returns>
        public static UserIdentityAzure ToAzureModel(this UserIdentity userIdentity)
        {
            var azureModel = new UserIdentityAzure
            {
                Id                        = userIdentity.Id,
                HashType                  = (int)userIdentity.HashType,
                HashedPassword            = userIdentity.HashedPassword,
                LoginEmail                = userIdentity.LoginEmail,
                EmailConfirmationCode     = userIdentity.EmailConfirmationCode,
                EmailConfirmationAttempts = userIdentity.EmailConfirmationAttempts,
                Device                    = userIdentity.Device
            };

            if (userIdentity.VkIdentity != null)
            {
                var vk = userIdentity.VkIdentity;
                azureModel.Vk_Id           = (int)vk.Id;
                azureModel.Vk_UniversityId = (int?)vk.UniversityId;
                azureModel.Vk_CityId       = (int?)vk.CityId;
                azureModel.Vk_CountryId    = (int?)vk.CountryId;
                if (vk.Counters != null)
                {
                    var count = vk.Counters;
                    azureModel.Vk_Counters_Audios    = (int?)count.Audios;
                    azureModel.Vk_Counters_Followers = (int?)count.Followers;
                    azureModel.Vk_Counters_Friends   = (int?)count.Friends;
                    azureModel.Vk_Counters_Photos    = (int?)count.Photos;
                    azureModel.Vk_Counters_Videos    = (int?)count.Videos;
                }
            }

            return(azureModel);
        }
Exemple #2
0
        /// <summary>
        ///     Froms the azure model.
        /// </summary>
        /// <param name="azureModel">The azure model.</param>
        /// <returns>UserIdentity.</returns>
        public static UserIdentity FromAzureModel(this UserIdentityAzure azureModel)
        {
            var vkCounters = new VkCounters
            {
                Audios    = (uint?)azureModel.Vk_Counters_Audios,
                Followers = (uint?)azureModel.Vk_Counters_Followers,
                Friends   = (uint?)azureModel.Vk_Counters_Friends,
                Photos    = (uint?)azureModel.Vk_Counters_Photos,
                Videos    = (uint?)azureModel.Vk_Counters_Videos,
            };
            var vkIdentity = new VkIdentity
            {
                CityId       = (uint?)azureModel.Vk_CityId,
                CountryId    = (uint?)azureModel.Vk_CountryId,
                Id           = (uint)azureModel.Vk_Id,
                UniversityId = (uint?)azureModel.Vk_UniversityId,
                Counters     = vkCounters
            };
            var identity = new UserIdentity
            {
                HashType                  = (HashType)azureModel.HashType,
                HashedPassword            = azureModel.HashedPassword,
                Id                        = azureModel.Id,
                LoginEmail                = azureModel.LoginEmail,
                VkIdentity                = vkIdentity,
                EmailConfirmationCode     = azureModel.EmailConfirmationCode,
                EmailConfirmationAttempts = (byte)azureModel.EmailConfirmationAttempts,
                Device                    = azureModel.Device
            };

            return(identity);
        }