Beispiel #1
0
        public void Tweets()
        {
            var source = new TwitterSource();
            var data   = source.ByUser("weareabc", 5).ToList();

            Assert.IsNotNull(data);
            Assert.AreEqual <int>(5, data.Count());
        }
Beispiel #2
0
        public ActionResult Twitter()
        {
            using (new Service.PerformanceMonitor())
            {
                var user       = User.Identity.Data();
                var preference = new UserPreference()
                {
                    Application = Application.Current,
                    User        = user,
                };

                preference = userCore.Get(preference);
                var profile = new UserProfile()
                {
                    CreatedOn = user.CreatedOn,
                    Gravatar  = string.IsNullOrWhiteSpace(user.Email) ? null : user.Email.GetHexMD5(),
                    UserName  = user.UserName,
                    Email     = user.Email,
                    TimeZone  = preference.TimeZone,
                    MaximumAllowedApplications   = preference.MaximumAllowedApplications,
                    CurrentApplicationIdentifier = preference.CurrentApplication == null ? Guid.Empty : preference.CurrentApplication.Identifier,
                    TwitterHandle = preference.TwitterHandle,
                    AbcHandle     = preference.AbcHandle,
                    City          = preference.City,
                    Country       = preference.Country,
                    GitHubHandle  = preference.GitHubHandle,
                };

                if (!string.IsNullOrWhiteSpace(profile.TwitterHandle))
                {
                    try
                    {
                        var twitter = new TwitterSource();
                        profile.Tweets = twitter.ByUser(preference.TwitterHandle, 10).ToList();
                    }
                    catch (Exception ex)
                    {
                        log.Log(ex, EventTypes.Warning, (int)Fault.TwitterFailure);
                    }
                }

                this.ViewBag.Profiles = this.Profiles();

                return(View(profile));
            }
        }
        /// <summary>
        /// Default Page
        /// </summary>
        /// <remarks>
        /// GET: /
        /// </remarks>
        /// <returns>Action Result</returns>
        public ActionResult Index(string username)
        {
            if (!string.IsNullOrWhiteSpace(username))
            {
                var page = new ProfilePage()
                {
                    Handle = username,
                    ApplicationIdentifier = Application.Default.Identifier,
                };

                try
                {
                    var core = new UserCore();
                    page = core.Get(page);
                    if (null != page)
                    {
                        var user = new User()
                        {
                            Identifier = page.OwnerIdentifier,
                        };

                        var userApp = new UserApplication()
                        {
                            Application = Application.Default,
                            User        = user,
                        };

                        var userCore = new UserCore();
                        user = userCore.GetByIdentifier(userApp);
                        if (null != user)
                        {
                            var temp = user.Convert();
                            temp.Points = page.Points;
                            var publicProfile = temp.Convert();

                            var preference = new UserPreference()
                            {
                                Application = Application.Default,
                                User        = user,
                            };

                            preference = userCore.Get(preference);

                            publicProfile.Set(preference);

                            if (!string.IsNullOrWhiteSpace(publicProfile.TwitterHandle))
                            {
                                try
                                {
                                    var twitter = new TwitterSource();
                                    publicProfile.Tweets = twitter.ByUser(publicProfile.TwitterHandle, 10).ToList();
                                }
                                catch (Exception ex)
                                {
                                    logger.Log(ex, EventTypes.Warning, 999);
                                }
                            }

                            this.ViewBag.Gravatar      = publicProfile.Gravatar;
                            this.ViewBag.AbcHandle     = publicProfile.AbcHandle.ToLower();
                            this.ViewBag.GithubHandle  = publicProfile.GitHubHandle;
                            this.ViewBag.TwitterHandle = publicProfile.TwitterHandle;
                            return(this.View(publicProfile));
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Log(ex, EventTypes.Warning, 999);
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #4
0
        /// <summary>
        /// Default Page
        /// </summary>
        /// <remarks>
        /// GET: /
        /// </remarks>
        /// <returns>Action Result</returns>
        public ActionResult Index(string username)
        {
            using (new PerformanceMonitor())
            {
                if (!string.IsNullOrWhiteSpace(username))
                {
                    var page = new ProfilePage()
                    {
                        Handle = username,
                        ApplicationIdentifier = Application.Current.Identifier,
                    };

                    try
                    {
                        var core = new UserCore();
                        page = core.Get(page);
                        if (null != page)
                        {
                            var user = new User()
                            {
                                Identifier = page.OwnerIdentifier,
                            };

                            var userApp = new UserApplication()
                            {
                                Application = Application.Current,
                                User        = user,
                            };

                            var userCore = new UserCore();
                            user = userCore.GetByIdentifier(userApp);
                            if (null != user)
                            {
                                var publicProfile = user.Convert().Convert();

                                var preference = new UserPreference()
                                {
                                    Application = Application.Current,
                                    User        = user,
                                };

                                preference = userCore.Get(preference);

                                publicProfile.Set(preference);

                                if (!string.IsNullOrWhiteSpace(publicProfile.TwitterHandle))
                                {
                                    try
                                    {
                                        var twitter = new TwitterSource();
                                        publicProfile.Tweets = twitter.ByUser(publicProfile.TwitterHandle, 10).ToList();
                                    }
                                    catch (Exception ex)
                                    {
                                        log.Log(ex, EventTypes.Warning, (int)Fault.TwitterFailure);
                                    }
                                }
                                return(this.View(publicProfile));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Log(ex, EventTypes.Warning, (int)ServiceFault.Empty);
                    }
                }

                return(this.RedirectToAction("Index", "Home"));
            }
        }