public void TestOwnerDeleteGroup()
        {
            //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);

            //User1 creates group
            long group1Id = recommendationGroupService.CreateGroup("tesNameGroup1", "testDescriptionGroup1", "testLogin1");

            // 2 User on Group1
            recommendationGroupService.AddUserToGroup("testLogin2", group1Id);
            recommendationGroupService.AddUserToGroup("testLogin3", group1Id);

            // User 1(owner) delete Group
            recommendationGroupService.DeleteGroup("testLogin1", group1Id);

            //Check Users on Group
            List <DTOGroups> groupsList = recommendationGroupService.ShowAllGroups();

            Assert.AreEqual(groupsList.Count, 0);

            List <DTOGroupsUser> groupsUser1 = recommendationGroupService.ShowUserGroups("testLogin1");
            List <DTOGroupsUser> groupsUser2 = recommendationGroupService.ShowUserGroups("testLogin2");
            List <DTOGroupsUser> groupsUser3 = recommendationGroupService.ShowUserGroups("testLogin3");

            Assert.AreEqual(groupsUser1.Count, 0);
            Assert.AreEqual(groupsUser2.Count, 0);
            Assert.AreEqual(groupsUser3.Count, 0);
        }
Exemplo n.º 2
0
        /// <summary>Handles the RowDataBound event of the gvAllGroups control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridViewRowEventArgs" /> instance containing the event data.</param>
        protected void GvAllGroups_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (SessionManager.IsUserAuthenticated(Context) &&
                e.Row.RowType == DataControlRowType.DataRow)
            {
                HttpCookie  cookie     = Request.Cookies["loginName"];
                IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();
                //Quiza despues en vez de DTOs, añado al viewState todos los ids.
                List <DTOGroupsUser> groupsFromUser = recommendationGroupService.ShowUserGroups(cookie.Value);

                long idRow       = Convert.ToInt64(gvAllGroups.DataKeys[e.Row.RowIndex].Values[0].ToString());
                bool coincidence = false;
                //this.lblError.Text += "RowDataBound id= " + idRow;
                //this.lblError.Visible = true;
                foreach (DTOGroupsUser group in groupsFromUser)
                {
                    if (idRow == group.group_usersId)
                    {
                        coincidence = true;
                        break;
                    }
                }

                if (coincidence)
                {
                    var lbl = (Label)e.Row.FindControl("lblSubscribed");
                    var lnk = (HyperLink)e.Row.FindControl("lnkSubscribeAuth");
                    if (lbl != null)
                    {
                        //lbl.Text = "Already subscribed";
                        lbl.Visible = true;
                    }
                    if (lnk != null)
                    {
                        lnk.Visible = false;
                    }
                }
                else
                {
                    var lnk = (HyperLink)e.Row.FindControl("lnkSubscribeAuth");
                    if (lnk != null)
                    {
                        lnk.Visible = false;
                    }
                    var lnkAuthUser = (LinkButton)e.Row.FindControl("lnkSubscribeUser");
                    if (lnkAuthUser != null)
                    {
                        lnkAuthUser.Visible = true;
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                long eventId;
                try
                {
                    eventId = Convert.ToInt64(Request.Params.Get("eventId"));
                }
                catch (ArgumentNullException)
                {
                    //Hacer un redirect a los grupos
                    eventId = 0;
                }

                if (eventId != 0)
                {
                    ViewState["eventId"] = eventId;
                    IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                    IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();

                    HttpCookie           cookie      = Request.Cookies["loginName"];
                    List <DTOGroupsUser> groupsUsers = recommendationGroupService.ShowUserGroups(cookie.Value);

                    if (groupsUsers.Count == 0)
                    {
                        this.lblEvents.Visible               = false;
                        lclRecommendation.Visible            = false;
                        txtRecommend.Visible                 = false;
                        lblNoGroupsToRecommend.Visible       = true;
                        lblSelectCheckBox.Visible            = false;
                        this.btnCreateRecommendation.Visible = false;
                        return;
                    }

                    DataTable table = new DataTable();
                    using (var reader = ObjectReader.Create(groupsUsers, "group_usersId", "gr_name"))
                    {
                        table.Load(reader);
                    }
                    ViewState["groupsRecommend"] = table;
                    this.gvGroups.DataSource     = (DataTable)ViewState["groupsRecommend"];
                    this.DataBind();
                    this.gvGroups.Columns[0].Visible = false;
                }
                else
                {
                    lblNoeventId.Visible            = true;
                    txtRecommend.Visible            = false;
                    btnCreateRecommendation.Visible = false;
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();

                HttpCookie           cookie      = Request.Cookies["loginName"];
                List <DTOGroupsUser> groupsUsers = recommendationGroupService.ShowUserGroups(cookie.Value);

                if (groupsUsers.Count == 0)
                {
                    lblNoGroups.Visible = true;
                    lblGroups.Visible   = false;
                    return;
                }
                lblGroups.Visible = false;

                #region //Forma normal

                //this.gvGroups.DataSource = groupsUsers;
                //this.DataBind();

                #endregion //Forma normal

                #region    //Forma opcional : Utilizando paquete Nuget: FastMember

                DataTable table = new DataTable();
                using (var reader = ObjectReader.Create(groupsUsers, "group_usersId", "gr_name"))
                {
                    table.Load(reader);
                }
                ViewState["groups"]      = table;
                this.gvGroups.DataSource = (DataTable)ViewState["groups"];;
                this.DataBind();

                this.gvGroups.Columns[0].Visible = false;

                #endregion //Forma opcional : Utilizando paquete Nuget: FastMember
            }
        }