Example #1
0
        public ActionResult Account()
        {
            var      data = UserProcessor.LoadUser(User.Identity.GetUserId());
            GameUser user = new GameUser
            {
                FirstName = data.Fname,
                LastName  = data.Lname,
                Age       = data.Age,
                Balance   = data.Balance
            };

            user.GamesBought = PurchaseProcessor.GetGamesBought(User.Identity.GetUserId());
            user.GamesSold   = PurchaseProcessor.GetGamesSold(User.Identity.GetUserId());
            var list = GameProcessor.GetGamesOnSale(User.Identity.GetUserId());

            user.GamesOnSale = new List <Game>();
            foreach (var row in list)
            {
                user.GamesOnSale.Add(new Game
                {
                    Name        = row.Name,
                    CreatedBy   = row.CreatedBy,
                    Year        = row.Year,
                    GameConsole = row.Console
                });
            }
            return(View(user));
        }
Example #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            /* if both textboxes are not empty
             * the login window will close and the
             * success window will open.
             * Ali*/
            if (isValid())
            {
                /* the program will send the username and password text fields to the
                 * UserProcessor class to make sure that the values are correct
                 * Ali*/
                var userInfo = await UserProcessor.LoadUser(txtUsername.Text, txtPassword.Password);

                /* If the user inputs an invalid username or password
                 * the User object's properites will all be null, so
                 * exception logic is required here
                 * Ali*/
                try
                {
                    if (userInfo.Privileges == "Admin")
                    {
                        UIRedesign s = new UIRedesign(userInfo);
                        Console.WriteLine(userInfo.Token);
                        s.Show();
                        this.Close();
                    }
                    else if (userInfo.Privileges == "Employee")
                    {
                    }
                    else
                    {
                        MessageBox.Show("Customers not permitted on this platform.", "Login Failed");
                    }
                }
                catch
                {
                    txtPassword.Clear();
                    MessageBox.Show("Either username or passord is incorrect.", "Login Failed");
                }
            }
        }