Example #1
0
        protected void LnkSubscribeUser_Click(object sender, EventArgs e)
        {
            lblError.Visible      = false;
            lblSubscribed.Visible = false;
            LinkButton  btn     = sender as LinkButton;
            GridViewRow row     = btn.NamingContainer as GridViewRow;
            long        groupId = Convert.ToInt64(gvAllGroups.DataKeys[row.RowIndex].Value.ToString());

            HttpCookie  cookie     = Request.Cookies["loginName"];
            IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();

            try
            {
                recommendationGroupService.AddUserToGroup(cookie.Value, groupId);
                var lnk = (LinkButton)row.FindControl("lnkSubscribeUser");

                if (lnk != null)
                {
                    lnk.Visible = false;
                }

                var lbl = (Label)row.FindControl("lblSubscribed");
                if (lbl != null)
                {
                    lbl.Visible = true;
                }
                this.lblSubscribed.Visible = true;
            }
            catch (Exception)
            {
                lblError.Text    = "Something go wrong";
                lblError.Visible = true;
            }
        }
        public void TestCreateGroupVariousUsers()
        {
            //Create user1
            UserProfileDetails user1Details = new UserProfileDetails("testUserName1", "testLastName1", "*****@*****.**", "en", "US");
            long userId = userService.RegisterUser("testLogin1", "passwordtest1", user1Details);
            //Create user2
            UserProfileDetails user2Details = new UserProfileDetails("testUserName2", "testLastName2", "*****@*****.**", "en", "US");
            long user2Id = userService.RegisterUser("testLogin2", "passwordtest2", user2Details);
            //Create user3
            UserProfileDetails user3Details = new UserProfileDetails("testUserName3", "testLastName3", "*****@*****.**", "en", "US");
            long user3Id = userService.RegisterUser("testLogin3", "passwordtest1", user3Details);
            //Create user4
            UserProfileDetails user4Details = new UserProfileDetails("testUserName4", "testLastName4", "*****@*****.**", "en", "US");
            long user4Id = userService.RegisterUser("testLogin4", "passwordtest4", user4Details);

            //User1 creates group
            long             group1Id  = recommendationGroupService.CreateGroup("tesNameGroup1", "testDescriptionGroup1", "testLogin1");
            List <DTOGroups> AllGroups = recommendationGroupService.ShowAllGroups();

            //All Users(4) on Group1
            recommendationGroupService.AddUserToGroup("testLogin2", group1Id);
            recommendationGroupService.AddUserToGroup("testLogin3", group1Id);
            recommendationGroupService.AddUserToGroup("testLogin4", group1Id);

            //Check 4 users on group
            AllGroups = recommendationGroupService.ShowAllGroups();
            DTOGroups groupTmp = AllGroups[0];

            //ICollection<UserProfile> usersOnGroup = groupTmp.UsersOnGroup;

            //Assert.AreEqual(usersOnGroup.Count, 4);

            //Check Users info
            //List<UserProfile> userList = new List<UserProfile>(usersOnGroup);
            //UserProfile user1 = userList[0];
            //UserProfile user2 = userList[1];
            //UserProfile user3 = userList[2];
            //UserProfile user4 = userList[3];

            //Assert.AreEqual(user1.userId, userId);
            //Assert.AreEqual(user2.userId, user2Id);
            //Assert.AreEqual(user3.userId, user3Id);
            //Assert.AreEqual(user4.userId, user4Id);

            //User3 abandon Group
            recommendationGroupService.AbandonGroup("testLogin3", group1Id);

            //Check Users on group
            AllGroups = recommendationGroupService.ShowAllGroups();
            //usersOnGroup = groupTmp.UsersOnGroup;
            //Assert.AreEqual(usersOnGroup.Count, 3);

            ////Check Users info
            //userList = new List<UserProfile>(usersOnGroup);
            //user1 = userList[0];
            //user2 = userList[1];
            //user4 = userList[2];

            //Assert.AreEqual(user1.userId, userId);
            //Assert.AreEqual(user2.userId, user2Id);
            //Assert.AreEqual(user4.userId, user4Id);
        }