Ejemplo n.º 1
0
        protected void SaveUserProfile(object sender, EventArgs e)
        {
            var user = new User
                           {
                               UserID = ((User) Session["userDetails"]).UserID,
                               FirstName = tbFirstName.Text,
                               LastName = tbLastName.Text,
                               Gender = Char.Parse(ddlGender.SelectedValue),
                               Email =  tbEmail.Text,
                               City =  tbCity.Text,
                               State = tbState.Text,
                               Age = int.Parse(tbAge.Text),
                               Height = int.Parse(tbHeight.Text),
                               Weight = int.Parse(tbWeight.Text)

                           };
            if (UserDAO.UpdateUserProfile(user))
            {
                Session["userDetails"] = UserDAO.GetUserFromUserId(user.UserID);
                Response.Redirect("~/Account/Profile.aspx");
            }else
            {
                Response.Redirect("~/Account/Profile.aspx");
            }
        }
Ejemplo n.º 2
0
        public void Initialize()
        {
            _user1 = new User
            {
                UserName = "******",
                FirstName = "Test",
                LastName = "Subject1",
                City = "Montreal",
                State = "QC",
                Gender = "M",
                Email = "*****@*****.**"
            };

            _user2 = new User
            {
                UserName = "******",
                FirstName = "Test",
                LastName = "Subject2",
                City = "Vancouver",
                State = "BC",
                Gender = "M",
                Email = "*****@*****.**"
            };

            _trans = new TransactionScope();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a new weather.
        /// </summary>
        /// <param name="sender">Object that requested the page load</param>
        /// <param name="e">The event arguments.</param>
        protected void CreateUser(object sender, EventArgs e)
        {
            if (UserDAO.GetUserFromUserName(txbUserName.Text) == null)
            {
                var user = new User { UserName = txbUserName.Text, FirstName = txbFirstName.Text, LastName = txbLastName.Text, Email = txbEmail.Text, Gender = (ddlGender.SelectedValue) };
                user.UserID = UserDAO.CreateNewUser(user, txbPassword.Text);

                string[] dateTime = DateTime.Now.ToString("MM/dd/yyyy h:mmtt").Split(' ');
                user.Post(new Message("Welcome to ActivEarth!", "See the tabs to the right to start you on your way to a more active lifestyle!",
                    user, dateTime[0], dateTime[1]));
                UserDAO.UpdateUserProfile(user);

                if (user.UserID == 0) {
                    ErrorMessage.Text = "A Database error occurred creating the User.";
                }
                else{
                    Session["userDetails"] = user;
                    Response.Redirect("~/Groups/Groups.aspx");
                }
            }
            else
            {
                ErrorMessage.Text = "A User with the given User Name already exists.  Please choose a different User Name.";
            }

            //UserDAO.CreateNewUser()
        }
Ejemplo n.º 4
0
        public void Initialize()
        {
            _user = new User("Test", "Subject");

            _user.Badges[Statistic.BikeDistance] =
                new Badge(1, "BikeDistance", _user, Statistic.BikeDistance,
                BadgeConstants.BikeDistance.REQUIREMENTS, BadgeConstants.BikeDistance.REWARDS,
                BadgeConstants.BikeDistance.IMAGES);

            _user.Badges[Statistic.WalkDistance] =
                new Badge(2, "WalkDistance", _user, Statistic.WalkDistance,
                BadgeConstants.WalkDistance.REQUIREMENTS, BadgeConstants.WalkDistance.REWARDS,
                BadgeConstants.WalkDistance.IMAGES);

            _user.Badges[Statistic.RunDistance] =
                new Badge(3, "RunDistance", _user, Statistic.RunDistance,
                BadgeConstants.RunDistance.REQUIREMENTS, BadgeConstants.RunDistance.REWARDS,
                BadgeConstants.RunDistance.IMAGES);

            _user.Badges[Statistic.Steps] =
                new Badge(4, "Steps", _user, Statistic.Steps,
                BadgeConstants.Steps.REQUIREMENTS, BadgeConstants.Steps.REWARDS,
                BadgeConstants.Steps.IMAGES);

            _user.Badges[Statistic.ChallengesCompleted] =
                new Badge(5, "ChallengesCompleted", _user, Statistic.ChallengesCompleted,
                BadgeConstants.Challenges.REQUIREMENTS, BadgeConstants.Challenges.REWARDS,
                BadgeConstants.Challenges.IMAGES);

            _user.SetStatistic(Statistic.BikeDistance, 0);
            _user.SetStatistic(Statistic.WalkDistance, 0);
            _user.SetStatistic(Statistic.RunDistance, 0);
            _user.SetStatistic(Statistic.Steps, 0);
            _user.SetStatistic(Statistic.ChallengesCompleted, 0);
        }
Ejemplo n.º 5
0
        public void TestUserWall()
        {
            var user1 = new User
            {
                UserName = "******",
                Age = 25,
                City = "Bleaksburg",
                Email = "*****@*****.**",
                FirstName = "I.C.",
                Gender = "M",
                Height = 60,
                LastName = "Poorcode",
                State = "VA",
                Weight = 130,
                ActivityScore = new Objects.Competition.ActivityScore(0,0,0)
            };

            var user2 = new User
            {
                UserName = "******",
                Age = 25,
                City = "Bleaksburg",
                Email = "*****@*****.**",
                FirstName = "I.C.",
                Gender = "M",
                Height = 60,
                LastName = "Poorcode",
                State = "VA",
                Weight = 130,
                ActivityScore = new Objects.Competition.ActivityScore(0, 0, 0)
            };

            user1.UserID = UserDAO.CreateNewUser(user1, "password");
            user2.UserID = UserDAO.CreateNewUser(user2, "password");

            Message message1 = new Message("Recent Activity 1", "User joined ActivEarth!", user1, "March 16 2012", "12:34:25 PM");
            user1.Post(message1);

            Message message2 = new Message("Recent Activity 2", "User ran 5 miles!", user2, "March 16 2012", "12:44:25 PM");
            Message message3 = new Message("Recent Activity 3", "User saved $10 in gas!", user2, "March 16 2012", "12:54:25 PM");
            user2.Post(message2);
            user2.Post(message3);

            UserDAO.UpdateUserProfile(user1);
            UserDAO.UpdateUserProfile(user2);

            User dbUser1 = UserDAO.GetUserFromUserId(user1.UserID);
            User dbUser2 = UserDAO.GetUserFromUserId(user2.UserID);
            Assert.AreEqual(dbUser1.Wall.Messages.Count, 1);
            Assert.AreEqual(dbUser1.Wall.Messages.First().Title, "Recent Activity 1");
            Assert.AreEqual(dbUser1.Wall.Messages.First().Text, "User joined ActivEarth!");
            Assert.AreEqual(dbUser1.Wall.Messages.First().Poster.UserName, "User1");
            Assert.AreEqual(dbUser2.Wall.Messages.Count, 2);
            Assert.AreEqual(dbUser2.Wall.Messages.First().Title, "Recent Activity 2");
            Assert.AreEqual(dbUser2.Wall.Messages.First().Text, "User ran 5 miles!");
            Assert.AreEqual(dbUser2.Wall.Messages.First().Poster.UserName, "User2");
            Assert.AreEqual(dbUser2.Wall.Messages.Last().Title, "Recent Activity 3");
            Assert.AreEqual(dbUser2.Wall.Messages.Last().Text, "User saved $10 in gas!");
            Assert.AreEqual(dbUser2.Wall.Messages.Last().Poster.UserName, "User2");
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Loas the page.
 /// </summary>
 /// <param name="sender">Object that sent the page request.</param>
 /// <param name="e">Event arguments.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     user = (User)Session["userDetails"];
     if (user == null)
     {
         Response.Redirect("~/Account/Login.aspx");
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a Message to be posted on a Group or User's Wall.
 /// </summary>
 /// <param name="title">The title of the Message</param>
 /// <param name="text">The text in the Message</param>
 /// <param name="poster">The User who posted the Message</param>
 public Message(string title, string text, User poster, string date, string time)
 {
     this.Title = title;
     this.Text = text;
     this.Poster = poster;
     this.Date = date;
     this.Time = time;
     this.PosterName = poster.UserName;
 }
Ejemplo n.º 8
0
        protected void CreateUser(object sender, EventArgs e)
        {
            if (UserDAO.GetUserFromUserName(txbUserName.Text) == null)
            {
                var user = new User { UserName = txbUserName.Text, FirstName = txbFirstName.Text, LastName = txbLastName.Text, Gender = Char.Parse(ddlGender.SelectedValue)};
                UserDAO.CreateNewUser(user, txbPassword.Text);
                Response.Redirect("RegisterConfirmation.aspx");
            }

            //UserDAO.CreateNewUser()
        }
Ejemplo n.º 9
0
        public void Initialize()
        {
            _user1 = new User("Test", "Subject1");
            _user2 = new User("Test", "Subject2");

            _allUsers = new Group(0, "All Users", _user1, string.Empty, new List<string>());
            _allUsers.Members.Add(_user1);
            _allUsers.Members.Add(_user2);

            _manager = new ChallengeManager(_allUsers);
            _trans = new TransactionScope();
        }
Ejemplo n.º 10
0
        public void TestCreateGroup()
        {
            var owner = new User
            {
                UserName = "******",
                Age = 25, City = "Bleaksburg", Email = "*****@*****.**", FirstName = "I.C.", Gender = "M",
                Height = 60, LastName = "Poorcode", State = "VA", Weight = 130
            };
            var member = new User
            {
                UserName = "******",
                Age = 25, City = "Bleaksburg", Email = "*****@*****.**", FirstName = "I.C.", Gender = "M",
                Height = 60, LastName = "Poorcode", State = "VA", Weight = 130
            };
            var notMember = new User
            {
                UserName = "******",
                Age = 25, City = "Bleaksburg", Email = "*****@*****.**", FirstName = "I.C.", Gender = "M",
                Height = 60, LastName = "Poorcode", State = "VA", Weight = 130
            };

            owner.UserID = UserDAO.CreateNewUser(owner, "password");
            member.UserID = UserDAO.CreateNewUser(member, "password");
            notMember.UserID = UserDAO.CreateNewUser(notMember, "password");

            List<string> tags = new List<string>();
            tags.Add("new");
            tags.Add("searchable");
            tags.Add("hashtags");

            Group testGroup = new Group("Test", owner, "This is a Group", tags);
            testGroup.Join(member);

            int id = GroupDAO.CreateNewGroup(testGroup);
            Assert.AreNotEqual(id, 0);

            Group dbGroup = GroupDAO.GetGroupFromGroupId(id);
            Assert.AreEqual("Test", dbGroup.Name);
            Assert.AreEqual("owner", dbGroup.Owner.UserName);
            Assert.AreEqual("This is a Group", dbGroup.Description);

            for (int i = 0; i < tags.Count; i++)
            {
                Assert.AreEqual(tags.ElementAt(i), dbGroup.HashTags.ElementAt(i));
            }

            Assert.AreEqual(2, dbGroup.Members.Count);
            foreach (User u in dbGroup.Members) {
                Assert.IsNotNull(u);
                Assert.AreNotEqual("notMember", u.UserName);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates a new badge belonging to a user, based on a specific statistic.
        /// </summary>
        /// <param name="user">User to whom the Badge is bound.</param>
        /// <param name="statistic">Statistic to which the Badge is bound.</param>
        public Badge(int id, string name, User user, Statistic statistic, 
            float[] levelValues, int[] levelPoints, Uri[] imagePaths)
        {
            this.ID = id;
            this.Name = name;
            this.Level = BadgeLevels.None;
            this.Progress = 0;

            _user = user;
            _statisticBinding = statistic;
            _levelRequirements = levelValues;
            _levelRewards = levelPoints;
            _ImagePaths = imagePaths;
        }
Ejemplo n.º 12
0
        public void Initialize()
        {
            _user1 = new User("Test", "Subject1");
            _user2 = new User("Test", "Subject2");
            _user3 = new User("Test", "Subject3");
            _user4 = new User("Test", "Subject4");

            _group1 = new Group(1, "Group 1", _user1, string.Empty, new List<string>());
            _group1.Members.Add(_user2);

            _group2 = new Group(2, "Group 2", _user3, string.Empty, new List<string>());
            _group2.Members.Add(_user4);
            _trans = new TransactionScope();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Returns the relative url for an image.
        /// 
        /// Current image sizes are:
        ///     - icon: a 150x150 image for the user's profile
        /// </summary>
        /// <param name="user">The user to retrieve the image for.</param>
        /// <param name="imageSizeName">The name of the image size to retrieve.</param>
        /// <returns></returns>
        private string getUserImageUrl(User user, string imageSizeName)
        {
            string path = Server.MapPath("~") + "\\Images\\Account\\UserProfile\\" + imageSizeName + "\\";
            int userImageDir = (user.UserID / 1000);
            string uploadPath = String.Format("{0}\\{1}\\{2}.png", path, userImageDir, user.UserID);

            if (System.IO.File.Exists(uploadPath))
            {
                return String.Format("/Images/Account/UserProfile/{0}/{1}/{2}.png", imageSizeName, userImageDir, user.UserID);
            }
            else
            {
                return String.Format("/Images/Account/UserProfileDefaults/default_{0}.png", imageSizeName);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates a new Group.
        /// 
        /// </summary>
        /// <param name="name">The name of the Group.</param>
        /// <param name="owner">The User that created the Group</param>
        /// <param name="description">A text description of the Group.</param>
        /// <param name="hashtags">A list of hashtags that can be used to search for the Group</param>
        public Group(string name, User owner, string description, List<string> hashtags)
        {
            this.Name = name;
            this.Owner = owner;
            this.Description = description;

            this.Members = new List<User>();
            this.Members.Add(owner);

            this.HashTags = hashtags;

            this.GreenScore = 0;
            this.ActivityScore = new ActivityScore();

            this.Wall = new Wall();
            this.Contests = new List<Contest>();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Creates a new Group.
        /// 
        /// </summary>
        /// <param name="id">A unique ID number identifying the Group.</param>
        /// <param name="name">The name of the Group.</param>
        /// <param name="owner">The User that created the Group</param>
        /// <param name="description">A text description of the Group.</param>
        /// <param name="hashtags">A list of hashtags that can be used to search for the Group</param>
        public Group(int id, string name, User owner, string description,
            List<string> hashtags)
        {
            this.ID = id;
            this.Name = name;
            this.Owner = owner;

            this.Members = new List<User>();
            this.Members.Add(owner);
            owner.Groups.Add(this);

            this.HashTags = hashtags;

            this.GreenScore = owner.GreenScore;
            this.ActivityScore = owner.ActivityScore;

            this.Wall = new Wall();
            this.Badges = new Dictionary<Statistic, Badge>();
            this.Contests = new List<int>();
        }
Ejemplo n.º 16
0
 public static int CreateNewUser(User user, string password)
 {
     try
     {
         using (SqlConnection connection = ConnectionManager.GetConnection())
         {
             var data = new ActivEarthDataProvidersDataContext(connection);
             var userData = new UserDataProvider { password = password, user_name = user.UserName };
             data.UserDataProviders.InsertOnSubmit(userData);
             var profileData = new ProfileDataProvider { UserDataProvider = userData, age = -1, city = "", email = user.Email, gender = user.Gender, height = -1, first_name = user.FirstName, last_name = user.LastName, state = "", weight = -1, green_score = 0, activity_score_total = 0, activity_score_contests = 0, activity_score_challenges = 0, activity_score_badges = 0 };
             data.ProfileDataProviders.InsertOnSubmit(profileData);
             data.SubmitChanges();
             return userData.id;
         }
     }
     catch
     {
         return 0;
     }
 }
Ejemplo n.º 17
0
        public static bool CreateNewUser(User user, string password)
        {
            try
            {

            using (SqlConnection connection = ConnectionManager.GetConnection())
            {
                var data = new ActivEarthDataProvidersDataContext(connection);
                var userData = new UserDataProvider {password = password, user_name = user.UserName,};
                data.UserDataProviders.InsertOnSubmit(userData);
                data.SubmitChanges();
                return true;

            }
            }
            catch (Exception)
            {

                return false;
            }
        }
Ejemplo n.º 18
0
        public void TestConfirmPassword()
        {
            using (_trans)
            {
                var user = new User
                {
                    UserName = "******",
                    Age = 25,
                    City = "Bleaksburg",
                    Email = "*****@*****.**",
                    FirstName = "I.C.",
                    Gender = 'M',
                    Height = 60,
                    LastName = "Poorcode",
                    State = "VA",
                    Weight = 130
                };
                UserDAO.CreateNewUser(user, "test");
                Assert.IsTrue(UserDAO.ConfirmPassword("test", UserDAO.GetUserIdFromUserName("testy123")));

            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Adds a user to the Contest.
        /// </summary>
        /// <param name="user">User to be added.</param>
        public static void AddUser(int contestId, User user)
        {
            if (!TeamDAO.UserCompetingInContest(user.UserID, contestId))
            {
                string teamName = String.Format("{0} {1}", user.FirstName, user.LastName);

                ContestTeam newTeam = new ContestTeam
                {
                    ContestId = contestId,
                    Name = teamName
                };

                int teamId = TeamDAO.CreateNewTeam(newTeam);
                TeamDAO.CreateNewTeamMember(user.UserID, teamId);
            }

            Contest contest = ContestDAO.GetContestFromContestId(contestId, false, false);
            contest.Reward = ContestManager.CalculateContestReward(
                ContestManager.CalculateEstimatedLengthInDays(contest),
                    TeamDAO.GetTeamsFromContestId(contestId, false).Count);
            ContestDAO.UpdateContest(contest);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Formats the table of Groups based on the given list of Groups and colors.
        /// </summary>
        /// <param name="groups">The list of messages to display in the table</param>
        /// <param name="backColors">The list of alternating background colors to display in the table</param>
        /// <param name="textColors">The list of alternating text colors to display in the table</param>
        public void PopulateGroupsTable(List<ActivEarth.Objects.Groups.Group> groups, Color[] backColors, Color[] textColors)
        {
            this.userDetails = (User)Session["userDetails"];

            int colorIndex = 0;
            int textIndex = 0;

            foreach (ActivEarth.Objects.Groups.Group group in groups)
            {
                _groupsTable.Rows.Add(MakeRowForTable(group, backColors[colorIndex], textColors[textIndex]));

                colorIndex++;
                if (colorIndex == backColors.Length)
                {
                    colorIndex = 0;
                }

                textIndex++;
                if (textIndex == textColors.Length)
                {
                    textIndex = 0;
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Adds a User's the list of Recent Acitivity Messages stored in the Database to the User's Wall.
        /// </summary>
        /// <param name="user">The User for which to retrieve Recent Activity Messages</param>
        public static void GetUserRecentActivity(User user)
        {
            try
            {
                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    var data = new ActivEarthDataProvidersDataContext(connection);

                    List<Message> messages = (from m in data.MessageDataProviders
                                              where m.group_id == -1 && m.user_id == user.UserID
                                              select
                                              new Message(m.title, m.message, UserDAO.GetUserFromUserId(m.user_id), m.date, m.time)
                                         ).ToList();

                    foreach (Message message in messages)
                    {
                        user.Post(message);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Save button click
        /// </summary>
        /// <param name="sender">Object that requested the page load</param>
        /// <param name="e">The event arguments.</param>
        protected void SaveUserProfile(object sender, EventArgs e)
        {
            if (tbAge.Text == "")
            {
                tbAge.Text = "0";
            }
            if (tbHeight.Text == "")
            {
                tbHeight.Text = "0";
            }
            if (tbWeight.Text == "")
            {
                tbWeight.Text = "0";
            }

            var user = new User
                           {
                               UserID = ((User)Session["userDetails"]).UserID,
                               FirstName = tbFirstName.Text,
                               LastName = tbLastName.Text,
                               Gender = ddlGender.SelectedValue,
                               Email =  tbEmail.Text,
                               City =  tbCity.Text,
                               State = tbState.Text,
                               Age = int.Parse(tbAge.Text),
                               Height = int.Parse(tbHeight.Text),
                               Weight = int.Parse(tbWeight.Text),
                               Wall = ((User)Session["userDetails"]).Wall
                           };

            if (pictureFile.HasFile)
            {
                string fileExtension = System.IO.Path.GetExtension(pictureFile.FileName);
                if (fileExtension == ".jpeg" || fileExtension == ".jpg" || fileExtension == ".png")
                {
                    try
                    {
                        string imgPath = getUploadPath(user.UserID, fileExtension);
                        pictureFile.SaveAs(imgPath);

                        resizeIcon(imgPath, user.UserID);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            else if (deletePhoto.Checked)
            {
                deletePhotos(user);
            }

            if (UserDAO.UpdateUserProfile(user))
            {
                Session["userDetails"] = UserDAO.GetUserFromUserId(user.UserID);
                Response.Redirect("~/Account/Profile.aspx");
            }
            else
            {
                Response.Redirect("~/Account/Profile.aspx");
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Delete profile photo
        /// </summary>
        /// <param name="user">The user which to delete photo from</param>
        private void deletePhotos(User user)
        {
            string[] newPhotoSizes = {"icon"};

            foreach (string photoSize in newPhotoSizes)
            {
                string userPhoto = userImageDirPath(photoSize, user.UserID) + user.UserID + ".png";
                if (File.Exists(userPhoto))
                {
                    File.Delete(userPhoto);
                }
            }

            string[] files = Directory.GetFiles(userImageDirPath("Original", user.UserID), user.UserID + ".*");
            if (files.Length > 0)
            {
                File.Delete(files[0]);
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Removes a User from the Group.
 /// </summary>
 /// <param name="quittingUser">The User to be removed from the Group.</param>
 public void Quit(User quittingUser)
 {
     this.Members.Remove(quittingUser);
     quittingUser.Groups.Remove(this);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Adds a User to the Group.
 /// </summary>
 /// <param name="newUser">The User to be added to the Group.</param>
 public void Join(User newUser)
 {
     this.Members.Add(newUser);
     newUser.Groups.Add(this);
 }
        /// <summary>
        /// Formats a single row for the Owner's table containing the given User.
        /// </summary>
        /// <param name="user">The User to display in the row</param>
        /// <param name="backColor">The background color to display in the row</param>
        /// <param name="textColor">The text color to display in the row</param>
        private TableRow MakeRowForOwnerTable(User user, Color backColor, Color textColor)
        {
            TableRow newRow = new TableRow();
            newRow.BackColor = backColor;
            newRow.Cells.Add(MakeImageCellForRow(user));
            newRow.Cells.Add(MakeTextCellForRow(user.UserName, textColor));

            User owner = (User)Session["userDetails"];
            if (owner.UserID == user.UserID)
            {
                newRow.Cells.Add(MakeTextCellForRow("Group Owner", textColor));
            }
            else
            {
                newRow.Cells.Add(MakeBootCellForRow(user.UserID));
            }
            return newRow;
        }
        /// <summary>
        /// Formats a cell to add to the row containing the given User's picture.
        /// </summary>
        /// <param name="User">The User whose image should be displayed in the cell</param>
        private TableCell MakeImageCellForRow(User user)
        {
            TableCell newCell = new TableCell();
            System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
            img.ImageUrl = getUserImageUrl(user, "icon");
            img.Height = new Unit(75, UnitType.Pixel);

            img.Width = new Unit(75, UnitType.Pixel);
            newCell.Controls.Add(img);
            return newCell;
        }
Ejemplo n.º 28
0
        public void TestGetBadgesFromUserId()
        {
            Log("Initializing users");

            User user1 = new User
            {
                UserName = "******",
                FirstName = "Test",
                LastName = "Subject79",
                City = "Boise",
                State = "ID",
                Gender = "M",
                Email = "*****@*****.**"
            };

            User user2 = new User
            {
                UserName = "******",
                FirstName = "Test",
                LastName = "Subject26",
                City = "Chicago",
                State = "IL",
                Gender = "F",
                Email = "*****@*****.**"
            };

            int user1ID = UserDAO.CreateNewUser(user1, "gesundheit");
            int user2ID = UserDAO.CreateNewUser(user2, "spatula");

            Log("Creating 6 badges for user1");
            BadgeManager.CreateBadge(user1ID, Statistic.Steps);
            BadgeManager.CreateBadge(user1ID, Statistic.BikeDistance);
            BadgeManager.CreateBadge(user1ID, Statistic.RunDistance);
            BadgeManager.CreateBadge(user1ID, Statistic.WalkDistance);
            BadgeManager.CreateBadge(user1ID, Statistic.GasSavings);
            BadgeManager.CreateBadge(user1ID, Statistic.ChallengesCompleted);

            Log("Creating 4 badges for user2");
            BadgeManager.CreateBadge(user2ID, Statistic.Steps);
            BadgeManager.CreateBadge(user2ID, Statistic.BikeDistance);
            BadgeManager.CreateBadge(user2ID, Statistic.RunDistance);
            BadgeManager.CreateBadge(user2ID, Statistic.WalkDistance);

            Log("Verifying user1's badge count");
            Assert.AreEqual(6, BadgeDAO.GetBadgesFromUserId(user1ID).Count);

            Log("Verifying user2's badge count");
            Assert.AreEqual(4, BadgeDAO.GetBadgesFromUserId(user2ID).Count);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Initializes a new user with fresh (level 0) badges.
        /// </summary>
        private void InitializeBadges()
        {
            _id = UserDAO.GetUserIdFromUserName("badgetest1");
            _user = UserDAO.GetUserFromUserId(_id);

            StatisticManager.SetUserStatistic(_id, Statistic.BikeDistance, 0);
            StatisticManager.SetUserStatistic(_id, Statistic.WalkDistance, 0);
            StatisticManager.SetUserStatistic(_id, Statistic.RunDistance, 0);
            StatisticManager.SetUserStatistic(_id, Statistic.Steps, 0);
            StatisticManager.SetUserStatistic(_id, Statistic.ChallengesCompleted, 0);
            StatisticManager.SetUserStatistic(_id, Statistic.GasSavings, 0);

            BadgeManager.CreateBadge(_id, Statistic.BikeDistance);
            BadgeManager.CreateBadge(_id, Statistic.WalkDistance);
            BadgeManager.CreateBadge(_id, Statistic.RunDistance);
            BadgeManager.CreateBadge(_id, Statistic.Steps);
            BadgeManager.CreateBadge(_id, Statistic.GasSavings);
            BadgeManager.CreateBadge(_id, Statistic.ChallengesCompleted);

            BadgeManager.UpdateBadge(_id, Statistic.BikeDistance);
            BadgeManager.UpdateBadge(_id, Statistic.WalkDistance);
            BadgeManager.UpdateBadge(_id, Statistic.RunDistance);
            BadgeManager.UpdateBadge(_id, Statistic.Steps);
            BadgeManager.UpdateBadge(_id, Statistic.GasSavings);
            BadgeManager.UpdateBadge(_id, Statistic.ChallengesCompleted);
        }
 /// <summary>
 /// Formats a single row for the table of all Users containing the given User.
 /// </summary>
 /// <param name="user">The User to display in the row</param>
 /// <param name="backColor">The background color to display in the row</param>
 /// <param name="textColor">The text color to display in the row</param>
 private TableRow MakeRowForSeeAllTable(User user, Color backColor, Color textColor)
 {
     TableRow newRow = new TableRow();
     newRow.BackColor = backColor;
     newRow.Cells.Add(MakeImageCellForRow(user));
     newRow.Cells.Add(MakeTextCellForRow(user.UserName, textColor));
     return newRow;
 }