Ejemplo n.º 1
0
 public PublicProfile SaveProfile(PublicProfile profile, string userId)
 {
     profile.UserId = userId;
     _context.PublicProfiles.Add(profile);
     Save();
     return(profile);
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            parameters = args;

            ImplicitGrantAuth auth = new ImplicitGrantAuth(
                "6124e12cbb1c4e779faf7f0b52f42c51",
                "http://localhost:4002",
                "http://localhost:4002",
                Scope.UserReadPrivate | Scope.PlaylistModifyPublic | Scope.PlaylistModifyPrivate
                );

            auth.AuthReceived += async(sender, payload) =>
            {
                Console.Clear();
                auth.Stop();
                _spotify = new SpotifyWebAPI()
                {
                    TokenType   = payload.TokenType,
                    AccessToken = payload.AccessToken
                };
                _user = _spotify.GetPublicProfile("sergiorgiraldo");
                DoThings();
            };
            auth.Start();
            auth.OpenBrowser();
            Console.ReadLine();
            auth.Stop(0);
        }
Ejemplo n.º 3
0
        public void CopiesDataFromProfileTest()
        {
            var profile = Model.Create <Profile>();

            var sut = new PublicProfile(profile);

            sut.Should().BeEquivalentTo(profile, opt => opt.ExcludingMissingMembers());
        }
Ejemplo n.º 4
0
        public ViewResult EditProfile(PublicProfile profile)
        {
            _ppRepository.EditProfile(profile, User.Identity.GetUserId());

            return(View("~/Views/PublicProfile/Index.cshtml", new PublicProfileModel {
                Profile = profile
            }));
        }
Ejemplo n.º 5
0
        public void ShouldGetPublicProfile()
        {
            PublicProfile profile = GetFixture <PublicProfile>("public-user.json");

            _mock.Setup(client => client.DownloadJson <PublicProfile>(It.IsAny <string>())).Returns(profile);

            Assert.AreEqual(profile, _spotify.GetPublicProfile("wizzler"));
            _mock.Verify(client => client.DownloadJson <PublicProfile>(It.Is <string>(str => ContainsValues(str, "/users/wizzler"))), Times.Exactly(1));
        }
Ejemplo n.º 6
0
 private async Task InsertNewVoteAsync(int direction, PublicProfile profile, int ideaId)
 {
     var vote = new ProductIdeaVote
     {
         Direction     = direction,
         Issuer        = profile,
         ProductIdeaId = ideaId
     };
     await _context.ProductIdeaVotes.AddAsync(vote);
 }
 public void MergeFrom(TradingPlayer other)
 {
     if (other == null)
     {
         return;
     }
     if (other.PlayerId.Length != 0)
     {
         PlayerId = other.PlayerId;
     }
     if (other.publicProfile_ != null)
     {
         if (publicProfile_ == null)
         {
             publicProfile_ = new global::POGOProtos.Data.Player.PlayerPublicProfile();
         }
         PublicProfile.MergeFrom(other.PublicProfile);
     }
     excludedPokemon_.Add(other.excludedPokemon_);
     if (other.tradingPokemon_ != null)
     {
         if (tradingPokemon_ == null)
         {
             tradingPokemon_ = new global::POGOProtos.Data.Trading.TradingPokemon();
         }
         TradingPokemon.MergeFrom(other.TradingPokemon);
     }
     if (other.bonus_ != null)
     {
         if (bonus_ == null)
         {
             bonus_ = new global::POGOProtos.Inventory.Loot();
         }
         Bonus.MergeFrom(other.Bonus);
     }
     if (other.price_ != null)
     {
         if (price_ == null)
         {
             price_ = new global::POGOProtos.Inventory.Loot();
         }
         Price.MergeFrom(other.Price);
     }
     if (other.CanAffordTrading != false)
     {
         CanAffordTrading = other.CanAffordTrading;
     }
     if (other.HasConfirmed != false)
     {
         HasConfirmed = other.HasConfirmed;
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
Ejemplo n.º 8
0
        public void ShouldGetPublicProfile()
        {
            PublicProfile profile = GetFixture <PublicProfile>("public-user.json");

            _mock.Setup(client => client.DownloadJson <PublicProfile>(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >()))
            .Returns(new Tuple <ResponseInfo, PublicProfile>(ResponseInfo.Empty, profile));

            _spotify.UseAuth = false;
            Assert.AreEqual(profile, _spotify.GetPublicProfile("wizzler"));
            _mock.Verify(client => client.DownloadJson <PublicProfile>(
                             It.Is <string>(str => ContainsValues(str, "/users/wizzler")),
                             It.Is <Dictionary <string, string> >(headers => headers.Count == 0)), Times.Exactly(1));
        }
Ejemplo n.º 9
0
        public void CopiesSkillValuesInsteadOfCopyingReferenceTest()
        {
            var profile = Model.Create <Profile>();

            var sut = new PublicProfile(profile);

            sut.Skills.Should().NotBeSameAs(profile.Skills);

            foreach (var skill in profile.Skills)
            {
                var matchingSkill = sut.Skills.Single(x => x.Name == skill.Name);

                skill.Should().NotBeSameAs(matchingSkill);
            }
        }
Ejemplo n.º 10
0
        private void SetOpenGraphMetadata(PublicProfile profile)
        {
            if (profile != null)
            {
                ViewBag.Title = profile.FullName;

                ViewBag.Og = new OpenGraphMetadata
                {
                    Title       = profile.FullName,
                    Description = $"Науковий ступень: {profile.AcademicDegree}. Наукові інтереси: {profile.GetField("ScientificInterest")}. Вчене звання: {profile.AcademicStatus}",
                    Image       = profile.Photo,
                    SiteName    = "Intellect - КПІ ім. Ігоря Сікорського",
                    Url         = CampusClient.GetProfileCanonicalUrl(profile).ToString()
                };
            }
        }
Ejemplo n.º 11
0
        //attr:profile is optional, set to view a particular public profile
        public Profile(ProfileType type, PublicProfile profile = PublicProfile.SAMUEL_GIBBONS)
        {
            InitializeComponent();
            menu.initIndex(2);
            if (type == ProfileType.publicProfile)
            {
                foreach (UIElement child in detailsGrid.Children)
                {
                    if (child is TextBox)
                    {
                        ((TextBox)child).IsReadOnly = true;
                        MaterialDesignThemes.Wpf.TextFieldAssist.SetDecorationVisibility(child, Visibility.Hidden);
                        ((TextBox)child).BorderThickness = new Thickness(0);
                    }
                }
                detailsGrid.Children.Remove(this.editPhotosBtn);

                name.Text      = publicNames[(int)profile];
                age.Text       = publicAges[(int)profile].ToString();
                gender.Text    = publicGenders[(int)profile];
                job.Text       = publicJobs[(int)profile];
                education.Text = publicEducations[(int)profile];

                bio.Text = Profile.publicLoremIpsum.Aggregate((string a, string b) => { return(a + b); });
            }
            else
            {
                detailsGrid.Children.Remove(messageBtn);
                name.Text       = personalName;
                name.IsReadOnly = false;

                age.Text       = personalAge.ToString();
                gender.Text    = personalGender;
                age.IsReadOnly = true;
                MaterialDesignThemes.Wpf.TextFieldAssist.SetDecorationVisibility(age, Visibility.Hidden);
                age.BorderThickness = new Thickness(0);
                gender.IsReadOnly   = true;
                MaterialDesignThemes.Wpf.TextFieldAssist.SetDecorationVisibility(gender, Visibility.Hidden);
                gender.BorderThickness = new Thickness(0);

                job.Text       = personalJob;
                education.Text = personalEducation;
                bio.Text       = personalBio;
            }
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Submit([FromForm] MessageRequestViewModel messageRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            PublicProfile profile = null;

            if (!messageRequest.IsAnonymous && _signInManager.IsSignedIn(User))
            {
                profile = await _userManager.GetPublicProfileByUserAsync(User);
            }
            var model = new Message
            {
                Author      = profile,
                Content     = messageRequest.Content,
                PublishDate = DateTime.Now
            };

            if (profile != null)
            {
                var baseValue      = ReviewSubmitExperienceReward;
                var recentMessages = await GetRecentMessagesCountAsync(profile) * SubsequentReviewModifier;

                baseValue = Math.Max(baseValue - recentMessages, 0);
                if (baseValue > 0)
                {
                    var realXpGained = profile.AddExperience(baseValue);
                    if (realXpGained > 0)
                    {
                        ViewBag.HasExperience    = true;
                        ViewBag.GainedExperience = baseValue;
                    }
                }
            }
            await _context.WebsiteReviews.AddAsync(model);

            await _context.SaveChangesAsync();

            _cache.Remove(Cache.LastReviews); // refresh the cache
            ViewBag.IsRecent = true;
            return(PartialView("_ReviewPartial", model));
        }
Ejemplo n.º 13
0
        public PublicProfile EditProfile(PublicProfile profile, string userId)
        {
            var dbEntry = _context.PublicProfiles.FirstOrDefault(e => e.UserId == userId);

            if (dbEntry != null)
            {
                dbEntry.ShowPurchaseHistory = profile.ShowPurchaseHistory;
                dbEntry.Avatar = profile.Avatar;
                dbEntry.City   = profile.City;
            }

            if (dbEntry.Name != profile.Name)
            {
                dbEntry.Name = profile.Name;
            }

            Save();
            return(dbEntry);
        }
Ejemplo n.º 14
0
        public Facebook()
        {
            var scopeList = new string[] { "public_profile", "user_friends", "email", "user_about_me", "user_actions.books", "user_actions.fitness", "user_actions.music", "user_actions.news", "user_actions.video", "user_actions:{app_namespace}", "user_birthday", "user_education_history", "user_events", "user_games_activity", "user_hometown", "user_likes", "user_location", "user_managed_groups", "user_photos", "user_posts", "user_relationships", "user_relationship_details", "user_religion_politics", "user_tagged_places", "user_videos", "user_website", "user_work_history", "read_custom_friendlists", "read_insights", "read_audience_network_insights", "read_page_mailboxes", "manage_pages", "publish_pages", "publish_actions", "rsvp_event", "pages_show_list", "pages_manage_cta", "pages_manage_instant_articles", "ads_read", "ads_management", "business_management", "pages_messaging", "pages_messaging_subscriptions", "pages_messaging_payments", "pages_messaging_phone_number" };

            Scope           = scopeList.ToList <string>();
            appID           = "1929285880642177";
            aPIVersion      = "v2.9";
            scopeParameter  = "&scope=";
            scopeParameter += string.Join(",", Scope.Where(s => s == "public_profile" || s == "email"));
            //if OAuth server not support "", use below as redirect URL
            //RedirectURL = "https://www.facebook.com/connect/login_success.html";
            Uri callBackUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri();

            RedirectURL          = callBackUri.AbsoluteUri;
            OptionalParameters   = "&display=popup&response_type=token";
            CurrentProviderTypes = ProviderTypes.FaceBook;
            Public_Profile       = new PublicProfile();
            //[Obsolete]
        }
Ejemplo n.º 15
0
        public async Task <PublicProfile> GetPublicProfile(Guid id, CancellationToken cancellationToken)
        {
            Ensure.Guid.IsNotEmpty(id, nameof(id));

            var profileTask    = FindProfile(id, cancellationToken);
            var categoriesTask = _query.GetCategories(ReadType.VisibleOnly, cancellationToken);

            // We will get both the visible categories and profile here at the same time
            // If the profile is not found, hidden or banned then this is wasted effort getting the category
            // These two scenarios are unlikely however so better overall to not get these two synchronously
            // Also, the categories are likely to be cached such that this will be a quick call even if it is redundant
            await Task.WhenAll(profileTask, categoriesTask).ConfigureAwait(false);

            var profile = profileTask.Result;

            if (profile == null)
            {
                return(null);
            }

            if (profile.Status == ProfileStatus.Hidden)
            {
                return(null);
            }

            if (profile.BannedAt != null)
            {
                return(null);
            }

            // Use a copy constructor before removing unapproved categories to ensure that changes don't corrupt the reference type stored in the cache
            var publicProfile = new PublicProfile(profile);

            var categories = categoriesTask.Result;

            // We want to split the categories into their groups
            // This will make it more efficient to enumerate through the categories by their groups against the profile
            var categoryGroups = SplitCategoryGroups(categories);

            RemoveUnapprovedCategories(publicProfile, categoryGroups);

            return(publicProfile);
        }
Ejemplo n.º 16
0
        private static void ProcessExperience(int diff, PublicProfile author, bool isFromDownVote = false)
        {
            if (diff == 0)
            {
                return;
            }
            var sign       = Math.Clamp(diff, -1, 1);
            var downvoteXp = diff * UpvoteExperienceBonus / 4;
            var xp         = UpvoteExperienceBonus * sign;

            if (isFromDownVote && diff <= 1)
            {
                xp = downvoteXp;
            }
            if (diff > 1 || diff < -1) // big vote (upvote -> downvote)
            {
                xp += (downvoteXp / diff) * sign;
            }
            author.AddExperience(xp);
        }
Ejemplo n.º 17
0
        public static Uri GetProfileCanonicalUrl(PublicProfile profile)
        {
            var position = GetUserPrimaryPosition(profile);

            var canonicalHost = "kpi.ua";
            var schema        = "https://";

            if (!String.IsNullOrEmpty(position?.Subdivision?.Url))
            {
                try
                {
                    var uri = new Uri(position.Subdivision.Url);
                    canonicalHost = uri.Host.ToLower();
                    schema        = "http://";
                }
                catch { }
            }

            return(new Uri($"{schema}intellect.{canonicalHost}/profile/{profile.UserIdentifier}"));
        }
Ejemplo n.º 18
0
        public void CanCreateDefaultProfileTest()
        {
            var sut = new PublicProfile();

            sut.About.Should().BeNull();
            sut.PhotoHash.Should().BeNull();
            sut.PhotoHash.Should().BeNull();
            sut.BirthYear.Should().BeNull();
            sut.FirstName.Should().BeNull();
            sut.Gender.Should().BeNull();
            sut.GitHubUsername.Should().BeNull();
            sut.Id.Should().BeEmpty();
            sut.Languages.Should().BeEmpty();
            sut.LastName.Should().BeNull();
            sut.Skills.Should().BeEmpty();
            sut.Status.Should().Be(ProfileStatus.Hidden);
            sut.TimeZone.Should().BeNull();
            sut.TwitterUsername.Should().BeNull();
            sut.Website.Should().BeNull();
            sut.YearStartedInTech.Should().BeNull();
        }
Ejemplo n.º 19
0
        private static void SetPublicInfo(MessageData data, DWMessage packet)
        {
            var profileInfo = new PublicProfileInfo();

            profileInfo.Deserialize(packet);

            /*ulong user = 0;
             * lock (DWRouter.Connections)
             * {
             *  user = (from conn in DWRouter.Connections
             *          where conn.Value == data.Get<string>("cid")
             *          select conn.Key).FirstOrDefault();
             * }*/
            ulong user = DWRouter.GetIDForData(data);

            var existing = Database.APublicProfile.Find(Query.EQ("user_id", (int)(user & 0xFFFFFFFF)));
            var item     = new PublicProfile();

            if (existing.Count() > 0)
            {
                item = existing.First();
            }

            item.user_id      = (int)(user & 0xFFFFFFFF);
            item.profile_int  = profileInfo.UnknownInt;
            item.profile_blob = profileInfo.ProfileData;
            item.blobsize     = profileInfo.ProfileData.Length;

            Database.APublicProfile.Save(item);


            var reply = packet.MakeReply(1, false);

            reply.ByteBuffer.Write(0x8000000000000001);
            reply.ByteBuffer.Write((uint)0);
            reply.ByteBuffer.Write((byte)8);
            reply.ByteBuffer.Write((uint)0);
            reply.ByteBuffer.Write((uint)0);
            reply.Send(true);
        }
Ejemplo n.º 20
0
        public SpotifyCollection(FullPlaylist playlist, IEnumerable <SpotifyTrack> items)
        {
            Items = items;

            Images = playlist.Images.Select(image => image.Url)
                     .ToArray();

            Uri           ownerUri;
            PublicProfile playlistOwner = playlist.Owner;

            try
            {
                ownerUri = new Uri(playlistOwner.ExternalUrls["spotify"]);
            }
            catch (KeyNotFoundException) // Should never fail
            {
                ownerUri = new Uri(playlistOwner.Uri);
            }

            Authors = new Dictionary <string, Uri>
            {
                { playlistOwner.DisplayName, ownerUri }
            };
            ExternUrls = new Dictionary <string, Uri>(
                playlist.ExternalUrls.Select(
                    pair => new KeyValuePair <string, Uri>(pair.Key, new Uri(pair.Value)))); // Convert value to URI
            Id   = playlist.Id;
            Name = playlist.Name;
            Type = playlist.Type;
            try
            {
                Uri = ExternUrls["spotify"];
            }
            catch (KeyNotFoundException) // Should never fail
            {
                // Convert Spotify URI to a track link (wont link track to playlist or album if it was linked)
                Uri = new Uri(playlist.Uri);
            }
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (PlayerId.Length != 0)
            {
                hash ^= PlayerId.GetHashCode();
            }
            if (publicProfile_ != null)
            {
                hash ^= PublicProfile.GetHashCode();
            }
            hash ^= excludedPokemon_.GetHashCode();
            if (tradingPokemon_ != null)
            {
                hash ^= TradingPokemon.GetHashCode();
            }
            if (bonus_ != null)
            {
                hash ^= Bonus.GetHashCode();
            }
            if (price_ != null)
            {
                hash ^= Price.GetHashCode();
            }
            if (CanAffordTrading != false)
            {
                hash ^= CanAffordTrading.GetHashCode();
            }
            if (HasConfirmed != false)
            {
                hash ^= HasConfirmed.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 22
0
        private void RemoveUnapprovedCategories(PublicProfile profile,
                                                IDictionary <CategoryGroup, IList <string> > categoryGroups)
        {
            var approvedGenders = categoryGroups[CategoryGroup.Gender];

            if (profile.Gender != null &&
                approvedGenders.Contains(profile.Gender.ToUpperInvariant()) == false)
            {
                // The gender is not an approved category
                profile.Gender = null;
            }

            // Take a copy of the languages so we can change the source while enumerating
            // ToList will copy the values for us
            var approvedLanguages = categoryGroups[CategoryGroup.Language];
            var profileLanguages  = profile.Languages.ToList();

            foreach (var profileLanguage in profileLanguages)
            {
                if (approvedLanguages.Contains(profileLanguage.ToUpperInvariant()) == false)
                {
                    profile.Languages.Remove(profileLanguage);
                }
            }

            // Take a copy of the skills so we can change the source while enumerating
            // ToList will copy the values for us
            var approvedSkills = categoryGroups[CategoryGroup.Skill];
            var profileSkills  = profile.Skills.ToList();

            foreach (var profileSkill in profileSkills)
            {
                if (approvedSkills.Contains(profileSkill.Name.ToUpperInvariant()) == false)
                {
                    profile.Skills.Remove(profileSkill);
                }
            }
        }
Ejemplo n.º 23
0
 public SpotifyUserProfile(PublicProfile publicProfile)
 {
     this.SubscriptionLevel = SpotifySubscriptionLevel.Unknown;
 }
Ejemplo n.º 24
0
        public static Position GetUserPrimaryPosition(PublicProfile profile)
        {
            var position = profile.Positions.FirstOrDefault(o => o.Employment == Employment.FullTime);

            return(position ?? profile.Positions.FirstOrDefault());
        }
Ejemplo n.º 25
0
 public static string GetLevelTitle(int lvl) => PublicProfile.GetTitle(GetLevel(lvl));
Ejemplo n.º 26
0
 public static string GetXpTitle(this IExperienceHolder holder) => PublicProfile.GetTitle(GetLevel(holder.Experience));
Ejemplo n.º 27
0
 private async Task <int> GetRecentMessagesCountAsync(PublicProfile profile, DateTime?relativeTo = null)
 {
     relativeTo = relativeTo ?? DateTime.Now;
     return(await _context.WebsiteReviews.Where(m =>
                                                m.AuthorId == profile.PublicProfileId && relativeTo.Value.Subtract(m.PublishDate) < TimeSpan.FromHours(3)).CountAsync());
 }