Exemple #1
0
    protected void btnShowGroupInfo_Click(object sender, EventArgs e)
    {
        UserContentManager contentmanager = new UserContentManager(ticket.Name);

        string groupname = ddlMemberGroupList.SelectedValue;

        try
        {
            List <group> usergroups = contentmanager.GetUserGroups();

            if (usergroups != null)
            {
                foreach (var group in usergroups)
                {
                    if (groupname == group.name)
                    {
                        Response.Redirect(String.Format("Group.aspx?Group={0}", group.group_id));
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
        }
    }
    protected void FillControls()
    {
        try
        {
            // Fill the dropdownlist with the users from the groups currently working
            // on the project the assignment will be a part of
            UserContentManager contentmanager = new UserContentManager(ticket.Name);
            string             project_id     = Request.QueryString["Project"];

            List <person> userquery = contentmanager.GetProjectUsers(project_id);

            if (userquery != null)
            {
                foreach (var user in userquery)
                {
                    ddlUserList.Items.Add(user.username);
                }
            }
            ddlUserList.Items.Insert(0, "Choose User");
        }
        catch (Exception ex)
        {
            lbmessages.Text = ex.Message;
        }
    }
    // Search the database for the persons the user is searching
    protected List <person> SearchPersons(string searchperson)
    {
        bool check_username    = true;
        bool check_eligibility = false;

        List <person> personstoadd = new List <person>();

        UserContentManager contentmanager = new UserContentManager(ticket.Name);

        try
        {
            string        project_id   = Request.QueryString["Project"];
            List <person> projectusers = contentmanager.GetProjectUsers(project_id);

            var persons = ctx.person.ToList();

            if (persons != null && searchperson != String.Empty)
            {
                foreach (var person in persons)
                {
                    check_username = true;

                    for (int i = 0; i < searchperson.Count(); i++)
                    {
                        if (searchperson[i] != person.username[i])
                        {
                            check_username = false;
                        }
                    }

                    foreach (var projectperson in projectusers)
                    {
                        if (projectperson.person_id == person.person_id)
                        {
                            check_eligibility = true;
                        }

                        if (!personstoadd.Contains(person))
                        {
                            if (check_username == true && check_eligibility == true)
                            {
                                personstoadd.Add(person);
                            }
                        }
                    }
                }
            }

            return(personstoadd);
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
            return(null);
        }
    }
    protected void FillControls()
    {
        try
        {
            // Fill the dropdownlist with the groups the current user belongs to
            UserContentManager contentmanager = new UserContentManager(ticket.Name);

            List <group> groupquery = contentmanager.GetUserGroups();

            if (groupquery != null)
            {
                foreach (var group in groupquery)
                {
                    ddlGroupList.Items.Add(group.name);
                }
            }
            ddlGroupList.Items.Insert(0, "Choose Group");
        }
        catch (Exception ex)
        {
            lbmessages.Text = ex.Message;
        }
    }
Exemple #5
0
    protected int CreateNewGroup()
    {
        ctx = new TeeMsEntities();
        int emptyrow = 0;
        int addedrow = 0;

        // First check for any gaps in the number sequence inside the database
        for (int i = 0; i <= ctx.group.Count(); i++)
        {
            group compareGroup = new group();
            var   checkGroup   = ctx.group.Where(gr => gr.group_tag == i).SingleOrDefault();

            if (checkGroup == compareGroup)
            {
                emptyrow = i;
            }
            else
            {
                compareGroup = checkGroup;
            }
        }

        if (emptyrow == 0)
        {
            addedrow = ctx.group.Count() + 1;
        }
        else
        {
            addedrow = emptyrow;
        }

        // Next add a new group to the database

        try
        {
            UserContentManager contentmanager = new UserContentManager(ticket.Name);
            List <group>       usergroupquery = contentmanager.GetUserGroups();
            int newgroupnamenro = 1;

            if (usergroupquery != null)
            {
                for (int i = 0; i < usergroupquery.Count; i++)
                {
                    if (usergroupquery[i].name == String.Format("New Group {0}", usergroupquery.Count + newgroupnamenro))
                    {
                        newgroupnamenro = newgroupnamenro + 1;
                        i = 0;
                    }
                }
            }

            string newgroupname = String.Format("New Group {0}", usergroupquery.Count + newgroupnamenro);

            var g = new group
            {
                name          = newgroupname,
                group_tag     = addedrow,
                creator       = ticket.Name,
                privacy       = 1,
                creation_date = DateTime.Now,
            };

            ctx.group.Add(g);
            ctx.SaveChanges();
            return(g.group_id);
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
            return(0);
        }
    }
Exemple #6
0
    protected void FillDivs()
    {
        // Fill your projects section with the users projects and assignments
        // and fill your groups with the users groups
        UserContentManager contentmanager = new UserContentManager(ticket.Name);

        try
        {
            List <group> usergroups = contentmanager.GetUserGroups();

            foreach (var group in usergroups)
            {
                var groupmembers = group.group_member.ToList();

                HtmlGenericControl groupdiv            = new HtmlGenericControl("div");
                HtmlGenericControl groupinnerdiv       = new HtmlGenericControl("div");
                HtmlGenericControl groupmemberdiv      = new HtmlGenericControl("div");
                HtmlGenericControl groupmemberinnerdiv = new HtmlGenericControl("div");
                HtmlGenericControl grouplink           = new HtmlGenericControl("a");
                HtmlGenericControl groupimage          = new HtmlGenericControl("img");
                HtmlGenericControl groupcut            = new HtmlGenericControl("hr");
                HtmlGenericControl groupmembertitle    = new HtmlGenericControl("h3");
                HtmlGenericControl groupmemberul       = new HtmlGenericControl("ul");

                groupdiv.Attributes.Add("class", "w3-container");
                groupdiv.ID = "divGroup" + group.group_id;

                groupinnerdiv.Attributes.Add("class", "w3-container");

                groupimage.Attributes.Add("src", group.group_picture_url);
                groupimage.Attributes.Add("alt", "Group image");
                groupimage.Attributes.Add("height", "150px");
                groupimage.Attributes.Add("width", "150px");
                groupimage.Attributes.Add("style", "float:left;");

                if (group.group_picture_url != null)
                {
                    if (group.group_picture_url != String.Empty)
                    {
                        groupimage.Attributes.Add("src", group.group_picture_url);
                    }
                }
                else
                {
                    groupimage.Attributes.Add("src", Request.ApplicationPath + "Images/no_image.png");
                }

                groupinnerdiv.Controls.Add(groupimage);

                grouplink.Attributes.Add("href", String.Format("Group.aspx?Group={0}", group.group_id));
                grouplink.Attributes.Add("style", "float:left; margin-top:5%; margin-left:5%;");
                grouplink.InnerText = group.name;

                groupinnerdiv.Controls.Add(grouplink);

                groupcut.Attributes.Add("style", "color:#000;background-color:#000; height:5px;");

                groupmemberdiv.Attributes.Add("class", "w3-container");

                groupmembertitle.InnerText = "Group Members";

                groupmemberdiv.Controls.Add(groupmembertitle);

                groupmemberinnerdiv.Attributes.Add("style", "width:50%;");

                groupmemberul.Attributes.Add("class", "w3-ul");
                groupmemberul.Attributes.Add("id", "groupmemberul");

                foreach (var member in groupmembers)
                {
                    HtmlGenericControl groupmemberli   = new HtmlGenericControl("li");
                    HtmlGenericControl groupmemberlink = new HtmlGenericControl("a");

                    groupmemberlink.Attributes.Add("href", String.Format("ViewUser.aspx?Person={0}", member.person.person_id));
                    groupmemberlink.InnerText = member.person.username;

                    groupmemberli.Attributes.Add("class", "w3-border");

                    groupmemberli.Controls.Add(groupmemberlink);
                    groupmemberul.Controls.Add(groupmemberli);
                }

                groupmemberinnerdiv.Controls.Add(groupmemberul);
                groupmemberdiv.Controls.Add(groupmemberinnerdiv);

                groupdiv.Controls.Add(groupinnerdiv);
                groupdiv.Controls.Add(groupmemberdiv);
                groupdiv.Controls.Add(groupcut);

                divYourGroups.Controls.Add(groupdiv);
            }
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
        }
    }
    protected int CreateNewProject()
    {
        // Initialize usercontentmanager class with the users username
        UserContentManager contentmanager = new UserContentManager(ticket.Name);

        string       projectname     = txtProjectName.Text;
        string       projectdesc     = txtProjectDescription.Text;
        string       projectcreator  = ticket.Name;
        string       grouptoaddname  = String.Empty;
        double       percent         = 0;
        string       applicationpath = Request.ApplicationPath;
        string       pictureuri      = applicationpath + "Images/no_image.png";
        List <group> groupquery      = new List <group>();
        bool         is_same_name    = false;

        bool gooduri = Uri.IsWellFormedUriString(txtPictureURI.Text, UriKind.Absolute);

        if (gooduri == true)
        {
            pictureuri = txtPictureURI.Text;
        }
        else
        {
            lbmessages.Text = "Enter valid absolute url path of the picture";
        }

        if (ddlGroupList.SelectedItem.Text != ddlGroupList.Items[0].Text)
        {
            grouptoaddname = ddlGroupList.SelectedItem.Text;

            groupquery = contentmanager.GetUserGroups();
        }

        DateTime duedate = calendarDueDate.SelectedDate;

        try
        {
            var rightperson = ctx.person.Where(p => p.username == projectcreator).FirstOrDefault();

            // Check that the user does not already have a project with the same name
            List <project> userprojects = contentmanager.GetUserProjects();

            foreach (var project in userprojects)
            {
                if (project.name == projectname)
                {
                    is_same_name = true;
                }
            }

            if (is_same_name == false)
            {
                // Search the right group given in the dropdownlist
                if (grouptoaddname != String.Empty)
                {
                    var rightgroup = ctx.group.Where(g => g.name == grouptoaddname);
                }

                int emptyrow = 0;
                int addedrow = 0;

                // First check for any gaps in the number sequence inside the database
                for (int i = 0; i <= ctx.project.Count(); i++)
                {
                    project compareProject = new project();
                    var     checkProject   = ctx.project.Where(gr => gr.project_id == i).FirstOrDefault();

                    if (checkProject == compareProject)
                    {
                        emptyrow = i;
                    }
                    else
                    {
                        compareProject = checkProject;
                    }
                }

                if (emptyrow == 0)
                {
                    addedrow = ctx.project.Count() + 1;
                }
                else
                {
                    addedrow = emptyrow;
                }

                // Insert new project into database
                var newproject = new project
                {
                    name            = projectname,
                    description     = projectdesc,
                    project_creator = rightperson.username,
                    creation_date   = DateTime.Now,
                    due_date        = duedate,
                    percent_done    = percent,
                    finished        = false,
                    privacy         = 1,
                    picture_url     = pictureuri
                };

                var projectlist = ctx.project.ToList();

                if (projectlist != null)
                {
                    int tagindex = 100;

                    foreach (var project in projectlist)
                    {
                        tagindex = (int)project.project_tag + 1;
                    }

                    newproject.project_tag = tagindex;
                }
                else
                {
                    newproject.project_tag = 100;
                }

                ctx.project.Add(newproject);
                ctx.SaveChanges();
                return(newproject.project_id);
            }
            else
            {
                lbmessages.Text = "Error: You already have a project with that name";
                return(-1);
            }
        }
        catch (Exception ex)
        {
            lbmessages.Text = ex.Message;
            return(-1);
        }
    }
Exemple #8
0
    protected void FillDivs(int user_id)
    {
        // Fill your projects section with the users projects and assignments
        // and fill your groups with the users groups

        try
        {
            var rightperson = ctx.person.Where(p => p.person_id == user_id).SingleOrDefault();


            if (rightperson != null)
            {
                UserContentManager contentmanager = new UserContentManager(rightperson.username);

                List <group>   usergroups   = contentmanager.GetUserGroups();
                List <project> userprojects = contentmanager.GetUserProjects();

                foreach (var project in userprojects)
                {
                    HtmlGenericControl projectdiv      = new HtmlGenericControl("div");
                    HtmlGenericControl projectinnerdiv = new HtmlGenericControl("div");
                    HtmlGenericControl projectlink     = new HtmlGenericControl("a");
                    HtmlGenericControl projectimage    = new HtmlGenericControl("img");
                    HtmlGenericControl projectcut      = new HtmlGenericControl("hr");

                    projectdiv.Attributes.Add("class", "w3-container");
                    projectdiv.ID = "divProject" + project.project_id;

                    projectinnerdiv.Attributes.Add("class", "w3-container");

                    projectimage.Attributes.Add("src", project.picture_url);
                    projectimage.Attributes.Add("alt", "Project image");
                    projectimage.Attributes.Add("height", "150px");
                    projectimage.Attributes.Add("width", "150px");
                    projectimage.Attributes.Add("style", "float:left;");

                    projectinnerdiv.Controls.Add(projectimage);

                    projectlink.Attributes.Add("href", String.Format("Project.aspx?Project={0}", project.project_id));
                    projectlink.Attributes.Add("style", "float:left; margin-top:5%; margin-left:5%;");
                    projectlink.InnerText = project.name;

                    projectinnerdiv.Controls.Add(projectlink);

                    projectcut.Attributes.Add("style", "color:#000;background-color:#000; height:5px;");

                    projectdiv.Controls.Add(projectinnerdiv);
                    projectdiv.Controls.Add(projectcut);

                    divUserProjects.Controls.Add(projectdiv);
                }

                foreach (var group in usergroups)
                {
                    HtmlGenericControl groupdiv      = new HtmlGenericControl("div");
                    HtmlGenericControl groupinnerdiv = new HtmlGenericControl("div");
                    HtmlGenericControl grouplink     = new HtmlGenericControl("a");
                    HtmlGenericControl groupimage    = new HtmlGenericControl("img");
                    HtmlGenericControl groupcut      = new HtmlGenericControl("hr");

                    groupdiv.Attributes.Add("class", "w3-container");
                    groupdiv.ID = "divGroup" + group.group_id;

                    groupinnerdiv.Attributes.Add("class", "w3-container");

                    groupimage.Attributes.Add("src", group.group_picture_url);
                    groupimage.Attributes.Add("alt", "Group image");
                    groupimage.Attributes.Add("height", "150px");
                    groupimage.Attributes.Add("width", "150px");
                    groupimage.Attributes.Add("style", "float:left;");

                    if (group.group_picture_url != null)
                    {
                        if (group.group_picture_url != String.Empty)
                        {
                            groupimage.Attributes.Add("src", group.group_picture_url);
                        }
                    }
                    else
                    {
                        groupimage.Attributes.Add("src", Request.ApplicationPath + "Images/no_image.png");
                    }

                    groupinnerdiv.Controls.Add(groupimage);

                    grouplink.Attributes.Add("href", String.Format("Group.aspx?Group={0}", group.group_id));
                    grouplink.Attributes.Add("style", "float:left; margin-top:5%; margin-left:5%;");
                    grouplink.InnerText = group.name;

                    groupinnerdiv.Controls.Add(grouplink);

                    groupcut.Attributes.Add("style", "color:#000;background-color:#000; height:5px;");

                    groupdiv.Controls.Add(groupinnerdiv);
                    groupdiv.Controls.Add(groupcut);

                    divUserGroups.Controls.Add(groupdiv);
                }
            }
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
        }
    }
    protected void FillComponentList()
    {
        try
        {
            int assignment_id = int.Parse(Request.QueryString["Assignment"]);
            int project_id    = int.Parse(Request.QueryString["Project"]);

            UserContentManager contentmanager = new UserContentManager(ticket.Name);

            var rightassignment = ctx.assignment.Where(amt => amt.amt_id == assignment_id).SingleOrDefault();

            foreach (var assignmentcomponent in rightassignment.assignment_component.ToList())
            {
                List <person> assignmentpersons          = contentmanager.GetAssignmentUsers(rightassignment.amt_id);
                List <person> assignmentcomponentpersons = new List <person>();

                List <assignment_component_person> amtcompers = assignmentcomponent.assignment_component_person.ToList();

                foreach (var amtcomper in amtcompers)
                {
                    foreach (var assignmentperson in assignmentpersons)
                    {
                        if (assignmentperson.person_id == amtcomper.person_id && !assignmentcomponentpersons.Contains(assignmentperson))
                        {
                            assignmentcomponentpersons.Add(assignmentperson);
                        }
                    }
                }

                HtmlGenericControl componentdiv         = new HtmlGenericControl("div");
                HtmlGenericControl componentborderdiv   = new HtmlGenericControl("div");
                HtmlGenericControl componentlabeldiv    = new HtmlGenericControl("div");
                HtmlGenericControl componentul          = new HtmlGenericControl("ul");
                LinkButton         componentlabelbutton = new LinkButton();

                componentdiv.Attributes.Add("class", "divComponent");
                componentborderdiv.Attributes.Add("class", "divComponentBorder");

                if (assignmentcomponent.finished == false)
                {
                    componentborderdiv.Attributes.Add("style", "background-color:#6fa9d6;");
                }
                else if (assignmentcomponent.finished == true)
                {
                    componentborderdiv.Attributes.Add("style", "background-color:#28fc60;");
                }

                componentlabeldiv.Attributes.Add("class", "divComponentLabel");

                componentlabelbutton.ID              = String.Format("lbtnComponentName{0}", assignmentcomponent.amtc_id);
                componentlabelbutton.Text            = assignmentcomponent.name;
                componentlabelbutton.CommandArgument = "Hello";
                componentlabelbutton.Command        += new CommandEventHandler(LinkButtonClick);
                componentlabelbutton.CssClass        = "ComponentLabels";

                componentul.Attributes.Add("id", "assignmentcomponentul");

                componentlabeldiv.Controls.Add(componentlabelbutton);

                foreach (var componentperson in assignmentcomponentpersons)
                {
                    HtmlGenericControl componentli         = new HtmlGenericControl("li");
                    HtmlGenericControl componentpersonlink = new HtmlGenericControl("a");

                    componentpersonlink.Attributes.Add("href", String.Format("ViewUser.aspx?Person={0}", componentperson.person_id));
                    componentpersonlink.InnerText = componentperson.username;

                    componentli.Controls.Add(componentpersonlink);
                    componentul.Controls.Add(componentli);
                }

                componentborderdiv.Controls.Add(componentlabeldiv);
                componentborderdiv.Controls.Add(componentul);
                componentdiv.Controls.Add(componentborderdiv);

                divAssignmentComponents.Controls.Add(componentdiv);
            }
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
        }
    }
Exemple #10
0
    protected void FillControls(int project_id)
    {
        try
        {
            UserContentManager contentmanager = new UserContentManager(ticket.Name);

            var usergroups = contentmanager.GetUserGroups();

            // Set the titles of the page to be the name of the group
            var rightproject = ctx.project.Where(g => g.project_id == project_id).SingleOrDefault();

            if (rightproject.finished == true)
            {
                btnArchiveProject.Text       = "Unarchive project";
                lbConfirmArchiveProject.Text = "Are you sure you wish to unarchive this project?";
            }

            // Fill ddlMemberGroupList with groups currently working on the project
            var          projectgroupquery = ctx.project_group.ToList();
            List <group> groups_in_project = new List <group>();

            if (projectgroupquery != null)
            {
                foreach (var projectgroup in projectgroupquery)
                {
                    if (projectgroup.project_id == rightproject.project_id)
                    {
                        groups_in_project.Add(ctx.group.Where(g => g.group_id == projectgroup.group_id).SingleOrDefault());
                    }
                }

                foreach (var group in groups_in_project)
                {
                    ddlMemberGroupList.Items.Add(group.name);
                }
            }
            ddlMemberGroupList.Items.Insert(0, "Choose Group");

            List <group> projectgroups_perm = groups_in_project;
            Session["projectgroups"] = projectgroups_perm;

            // Fill ddlAssignmentList with groups currently working on the project
            List <assignment> projectassignments = rightproject.assignment.ToList();

            if (projectassignments != null)
            {
                foreach (var assignment in projectassignments)
                {
                    ddlAssignmentList.Items.Add(assignment.name);
                }
            }
            ddlAssignmentList.Items.Insert(0, "Choose Assignment");

            Session["ProjectAssignments"] = projectassignments;

            // Set due date to calendar
            if (rightproject.due_date != null)
            {
                calendarDueDate.SelectedDate = (DateTime)rightproject.due_date;
                calendarDueDate.VisibleDate  = (DateTime)rightproject.due_date;
            }

            if (rightproject.assignment.Count > 0)
            {
                FillProjectAssignmentProgress();
            }

            FillComments();
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
        }
    }
Exemple #11
0
    protected void FillDivs()
    {
        // Fill your projects section with the users projects and assignments
        // and fill your groups section with the users groups
        UserContentManager contentmanager = new UserContentManager(ticket.Name);

        try
        {
            List <group>   usergroups   = contentmanager.GetUserGroups();
            List <project> userprojects = contentmanager.GetUserProjects();

            foreach (var project in userprojects)
            {
                var projectassignments = project.assignment.ToList();

                HtmlGenericControl projectdiv                = new HtmlGenericControl("div");
                HtmlGenericControl projectinnerdiv           = new HtmlGenericControl("div");
                HtmlGenericControl projectassignmentdiv      = new HtmlGenericControl("div");
                HtmlGenericControl projectassignmentinnerdiv = new HtmlGenericControl("div");
                HtmlGenericControl projectlink               = new HtmlGenericControl("a");
                HtmlGenericControl projectimage              = new HtmlGenericControl("img");
                HtmlGenericControl projectcut                = new HtmlGenericControl("hr");
                HtmlGenericControl projectassignmenttitle    = new HtmlGenericControl("h3");
                HtmlGenericControl projectassignmentul       = new HtmlGenericControl("ul");

                projectdiv.Attributes.Add("class", "w3-container");
                projectdiv.ID = "divProject" + project.project_id;

                projectinnerdiv.Attributes.Add("class", "w3-container");

                projectimage.Attributes.Add("src", project.picture_url);
                projectimage.Attributes.Add("alt", "Project image");
                projectimage.Attributes.Add("height", "150px");
                projectimage.Attributes.Add("width", "150px");
                projectimage.Attributes.Add("style", "float:left;");

                projectinnerdiv.Controls.Add(projectimage);

                projectlink.Attributes.Add("href", String.Format("Project.aspx?Project={0}", project.project_id));
                projectlink.Attributes.Add("style", "float:left; margin-top:5%; margin-left:5%;");
                projectlink.InnerText = project.name;

                projectinnerdiv.Controls.Add(projectlink);

                projectcut.Attributes.Add("style", "color:#000;background-color:#000; height:5px;");

                projectassignmentdiv.Attributes.Add("class", "w3-container");

                projectassignmenttitle.InnerText = "Assignments";

                projectassignmentdiv.Controls.Add(projectassignmenttitle);

                projectassignmentinnerdiv.Attributes.Add("style", "width:15%;");

                projectassignmentul.Attributes.Add("class", "w3-ul w3-border");
                projectassignmentul.Attributes.Add("id", "projectassignmentsul");

                foreach (var assignment in projectassignments)
                {
                    HtmlGenericControl projectassignmentli   = new HtmlGenericControl("li");
                    HtmlGenericControl projectassignmentlink = new HtmlGenericControl("a");

                    projectassignmentlink.Attributes.Add("href", String.Format("Assignment.aspx?Assignment={0}&Project={1}", assignment.amt_id, project.project_id));
                    projectassignmentlink.InnerText = assignment.name;

                    projectassignmentli.Controls.Add(projectassignmentlink);
                    projectassignmentul.Controls.Add(projectassignmentli);
                }

                projectassignmentinnerdiv.Controls.Add(projectassignmentul);
                projectassignmentdiv.Controls.Add(projectassignmentinnerdiv);

                projectdiv.Controls.Add(projectinnerdiv);
                projectdiv.Controls.Add(projectassignmentdiv);
                projectdiv.Controls.Add(projectcut);

                divYourProjects.Controls.Add(projectdiv);
            }
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
        }
    }
Exemple #12
0
    protected int CreateNewGroup()
    {
        ctx = new TeeMsEntities();

        try
        {
            // First add a new group to the database

            UserContentManager contentmanager = new UserContentManager(ticket.Name);
            List <group>       usergroupquery = contentmanager.GetUserGroups();
            int newgroupnamenro = 1;

            if (usergroupquery != null)
            {
                for (int i = 0; i < usergroupquery.Count; i++)
                {
                    if (usergroupquery[i].name == String.Format("New Group {0}", usergroupquery.Count + newgroupnamenro))
                    {
                        newgroupnamenro = newgroupnamenro + 1;
                        i = 0;
                    }
                }
            }

            string newgroupname = String.Format("New Group {0}", usergroupquery.Count + newgroupnamenro);

            var g = new group
            {
                name          = newgroupname,
                creator       = ticket.Name,
                privacy       = 1,
                creation_date = DateTime.Now,
            };

            var grouplist = ctx.group.ToList();

            if (grouplist != null)
            {
                int tagindex = 100;

                foreach (var group in grouplist)
                {
                    tagindex = (int)group.group_tag + 1;
                }

                g.group_tag = tagindex;
            }
            else
            {
                g.group_tag = 100;
            }

            ctx.group.Add(g);
            ctx.SaveChanges();
            return(g.group_id);
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
            return(0);
        }
    }
Exemple #13
0
    protected void FillDivs()
    {
        // Fill your projects section with the users projects and assignments
        // and fill your groups with the users groups
        UserContentManager contentmanager = new UserContentManager(ticket.Name);

        try
        {
            divYourGroups.Controls.Clear();
            divYourProjects.Controls.Clear();

            List <group>   usergroups   = contentmanager.GetUserGroups();
            List <project> userprojects = contentmanager.GetUserProjects();

            // First fill the projects section of the page
            foreach (var project in userprojects)
            {
                HtmlGenericControl projectdiv      = new HtmlGenericControl("div");
                HtmlGenericControl projectinnerdiv = new HtmlGenericControl("div");
                HtmlGenericControl projectlink     = new HtmlGenericControl("a");
                HtmlGenericControl projectimage    = new HtmlGenericControl("img");
                HtmlGenericControl projectcut      = new HtmlGenericControl("hr");

                projectdiv.Attributes.Add("class", "w3-container");
                projectdiv.ID = "divProject" + project.project_id;

                projectinnerdiv.Attributes.Add("class", "w3-container");

                projectimage.Attributes.Add("alt", "Project image");
                projectimage.Attributes.Add("height", "150px");
                projectimage.Attributes.Add("width", "150px");
                projectimage.Attributes.Add("style", "float:left;");

                // if the group has an exsiting picture in the database, we'll fetch it
                if (project.picture_url != null)
                {
                    if (project.picture_url != String.Empty)
                    {
                        projectimage.Attributes.Add("src", project.picture_url);
                    }
                }
                else
                {
                    projectimage.Attributes.Add("src", Request.ApplicationPath + "Images/no_image.png");
                }

                projectinnerdiv.Controls.Add(projectimage);

                projectlink.Attributes.Add("href", String.Format("Project.aspx?Project={0}", project.project_id));
                projectlink.Attributes.Add("style", "float:left; margin-top:5%; margin-left:5%;");
                projectlink.InnerText = project.name;

                projectinnerdiv.Controls.Add(projectlink);

                projectcut.Attributes.Add("style", "color:#000;background-color:#000; height:5px;");

                projectdiv.Controls.Add(projectinnerdiv);
                projectdiv.Controls.Add(projectcut);

                divYourProjects.Controls.Add(projectdiv);
            }

            // Next we'll fill the groups section of the page
            foreach (var group in usergroups)
            {
                HtmlGenericControl groupdiv      = new HtmlGenericControl("div");
                HtmlGenericControl groupinnerdiv = new HtmlGenericControl("div");
                HtmlGenericControl grouplink     = new HtmlGenericControl("a");
                HtmlGenericControl groupimage    = new HtmlGenericControl("img");
                HtmlGenericControl groupcut      = new HtmlGenericControl("hr");

                groupdiv.Attributes.Add("class", "w3-container");
                groupdiv.ID = "divGroup" + group.group_id;

                groupinnerdiv.Attributes.Add("class", "w3-container");

                groupimage.Attributes.Add("alt", "Group image");
                groupimage.Attributes.Add("height", "150px");
                groupimage.Attributes.Add("width", "150px");
                groupimage.Attributes.Add("style", "float:left;");

                // if the group has an exsiting picture in the database, we'll fetch it
                if (group.group_picture_url != null)
                {
                    if (group.group_picture_url != String.Empty)
                    {
                        groupimage.Attributes.Add("src", group.group_picture_url);
                    }
                }
                else
                {
                    groupimage.Attributes.Add("src", Request.ApplicationPath + "Images/no_image.png");
                }

                groupinnerdiv.Controls.Add(groupimage);

                grouplink.Attributes.Add("href", String.Format("Group.aspx?Group={0}", group.group_id));
                grouplink.Attributes.Add("style", "float:left; margin-top:5%; margin-left:5%;");
                grouplink.InnerText = group.name;

                groupinnerdiv.Controls.Add(grouplink);

                groupcut.Attributes.Add("style", "color:#000;background-color:#000; height:5px;");

                groupdiv.Controls.Add(groupinnerdiv);
                groupdiv.Controls.Add(groupcut);

                divYourGroups.Controls.Add(groupdiv);
            }
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
        }
    }