Esempio n. 1
0
        protected void btnSendInvite_Click(object sender, EventArgs e)
        {
            try
            {
                int totalchkboxes = Convert.ToInt32(totalaccountscheck.InnerHtml.ToString());
                string[] totalchkboxesArray = new string[totalchkboxes];

                int jj = 0;
                for (int i = 0; i < totalchkboxes; i++)
                {
                    if (Page.Request.Form["chkbox_" + i + ""] != null)
                    {
                        totalchkboxesArray[jj] = Page.Request.Form["chkbox_" + i + ""].ToString();
                        jj++;
                    }
                }

                if (jj > 0)
                {
                    if (!string.IsNullOrEmpty(txtEmail.Text) && !string.IsNullOrEmpty(txtFirstName.Text) && !string.IsNullOrEmpty(txtLastName.Text))
                    {
                        if (txtEmail.Text != "Enter Email Address" && txtFirstName.Text != "First Name" && txtLastName.Text != "Last Name")
                        {
                            if (rbAdmin.Checked || rbUser.Checked)
                            {
                                if (rbAdmin.Checked)
                                {
                                    AccessLevel = "admin";
                                }
                                else if (rbUser.Checked)
                                {
                                    AccessLevel = "user";
                                }

                                if (AccessLevel != string.Empty)
                                {
                                    TeamRepository teamrepo = new TeamRepository();
                                    Team team = null;
                                    User user = (User)Session["LoggedUser"];
                                    if (!teamrepo.checkTeamExists(txtEmail.Text, user.Id))
                                    {
                                        team = new Team();
                                        team.Id = Guid.NewGuid();
                                        team.FirstName = txtFirstName.Text;
                                        team.LastName = txtLastName.Text;
                                        team.StatusUpdateDate = DateTime.Now;
                                        team.EmailId = txtEmail.Text;
                                        team.UserId = user.Id;
                                        team.InviteStatus = 1;
                                        team.InviteDate = DateTime.Now;
                                        team.AccessLevel = AccessLevel;
                                        teamrepo.addNewTeam(team);
                                    }
                                    else
                                    {
                                        team = teamrepo.getMemberByEmailId(user.Id, txtEmail.Text);
                                    }
                                    MailSender.SendInvitationEmail(team.FirstName + " " + team.LastName, user.UserName, team.EmailId, team.Id);
                                    if (totalchkboxesArray.Count() != 0)
                                    {
                                        TeamMemberProfileRepository teammemberprofilerepo = new TeamMemberProfileRepository();
                                        foreach (var item in totalchkboxesArray)
                                        {
                                            try
                                            {
                                                if (!string.IsNullOrEmpty(item))
                                                {
                                                    string[] itemarray = item.Split('_');
                                                    TeamMemberProfile teammember = new TeamMemberProfile();
                                                    teammember.Id = Guid.NewGuid();
                                                    teammember.ProfileId = itemarray[1];
                                                    teammember.ProfileType = itemarray[0];
                                                    teammember.Status = 1;
                                                    teammember.StatusUpdateDate = DateTime.Now;
                                                    teammember.TeamId = team.Id;
                                                    if (!teammemberprofilerepo.checkTeamMemberProfile(teammember.TeamId, teammember.ProfileId))
                                                    {
                                                        teammemberprofilerepo.addNewTeamMember(teammember);
                                                    }
                                                    else
                                                    {
                                                        teammemberprofilerepo.updateTeamMember(teammember);
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine(ex.StackTrace);
                                            }
                                        }
                                        Response.Redirect("InviteMember.aspx");
                                    }
                                    txtFirstName.Text = "";
                                    txtLastName.Text = "";
                                    txtEmail.Text = "";
                                    rbAdmin.Checked = false;
                                    rbUser.Checked = false;
                                    Label1.Text = "Invitation Sends";
                                }

                            }
                        }
                    }

                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "MyFun1", "disp_confirm();", true);
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Esempio n. 2
0
        protected void btnSendInvite_Click(object sender, EventArgs e)
        {
            int totalchkboxes = Convert.ToInt32(totalaccountscheck.InnerHtml.ToString());
            string[] totalchkboxesArray = new string[totalchkboxes];
            int jj = 0;
            for (int i = 0; i < totalchkboxes; i++)
            {
                if (Page.Request.Form["chkbox_"+i+""] != null)
                {
                    totalchkboxesArray[jj] = Page.Request.Form["chkbox_" + i + ""].ToString();
                    jj++;
                }
            }

            if (!string.IsNullOrEmpty(txtEmail.Text) && !string.IsNullOrEmpty(txtFirstName.Text) && !string.IsNullOrEmpty(txtLastName.Text))
            {
                if (txtEmail.Text != "Enter Email Address" && txtFirstName.Text != "First Name" && txtLastName.Text != "Last Name")
                {
                    if (rbAdmin.Checked || rbUser.Checked)
                    {
                        if (AccessLevel != string.Empty)
                        {
                            TeamRepository teamrepo = new TeamRepository();
                            Team team = new Team();
                            User user = (User)Session["LoggedUser"];
                            team.Id = Guid.NewGuid();
                            team.FirstName = txtFirstName.Text;
                            team.LastName = txtLastName.Text;
                            team.StatusUpdateDate = DateTime.Now;
                            team.UserId = user.Id;
                            team.InviteStatus = 1;
                            team.InviteDate = DateTime.Now;
                            team.AccessLevel = AccessLevel;
                            team.EmailId = txtEmail.Text;

                            if (!teamrepo.checkTeamExists(team.EmailId, team.UserId))
                            {
                                teamrepo.addNewTeam(team);
                            }

                            /*mailsection**/

                            if (totalchkboxesArray.Count() != 0)
                            {
                                TeamMemberProfileRepository teammemberprofilerepo = new TeamMemberProfileRepository();
                                foreach (var item in totalchkboxesArray)
                                {
                                    string[] itemarray = item.Split('_');
                                    TeamMemberProfile teammember = new TeamMemberProfile();
                                    teammember.Id = Guid.NewGuid();
                                    teammember.ProfileId = itemarray[1];
                                    teammember.ProfileType = itemarray[0];
                                    teammember.Status = 1;
                                    teammember.StatusUpdateDate = DateTime.Now;
                                    teammember.TeamId = team.Id;
                                    if (!teammemberprofilerepo.checkTeamMemberProfile(teammember.TeamId, teammember.ProfileId))
                                    {
                                        teammemberprofilerepo.addNewTeamMember(teammember);
                                    }
                                    else
                                    {
                                        teammemberprofilerepo.updateTeamMember(teammember);
                                    }
                                }

                            }

                        }
                        else
                        {

                        }
                    }
                }
            }
        }