public void GetByIdentifierUserAppUserNull()
        {
            var userApp = new UserApplication()
            {
                Application = new Application(),
            };

            userApp.Application.Identifier = Guid.NewGuid();

            var core = new UserCore();

            core.GetByIdentifier(userApp);
        }
        public void GetByIdentifierUserAppApplicationNull()
        {
            var userApp = new UserApplication()
            {
                User = new User(),
            };

            userApp.User.Identifier = Guid.NewGuid();

            var core = new UserCore();

            core.GetByIdentifier(userApp);
        }
        public void GetByIdentifierUserAppUserIdentifierEmpty()
        {
            var userApp = new UserApplication()
            {
                User        = new User(),
                Application = new Application(),
            };

            userApp.User.Identifier        = Guid.Empty;
            userApp.Application.Identifier = Guid.NewGuid();

            var core = new UserCore();

            core.GetByIdentifier(userApp);
        }
        public void GetByIdentifier()
        {
            var data  = new UserData(StringHelper.ValidString(), StringHelper.ValidString(), StringHelper.ValidString());
            var table = new AzureTable <UserData>(ServerConfiguration.Default);

            table.AddEntity(data);

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

            userApp.User.Identifier        = data.Id;
            userApp.Application.Identifier = data.ApplicationId;

            var core = new UserCore();
            var got  = core.GetByIdentifier(userApp);

            Assert.IsNotNull(got);
            Assert.AreEqual <Guid>(data.Id, got.Identifier);
        }
        public void GetByIdentifierUserAppNull()
        {
            var core = new UserCore();

            core.GetByIdentifier(null);
        }
        /// <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 #7
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"));
            }
        }