Example #1
0
    protected void btnSendMessage_Click(object sender, EventArgs e)
    {
        Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        IEnumerable <ClubMember> lst = ClubMember.AdminsForClub(CurrentClub.ID);

        using (MailMessage msg = new MailMessage())
        {
            MailAddress maFrom = new MailAddress(pf.Email, pf.UserFullName);
            msg.From = new MailAddress(Branding.CurrentBrand.EmailAddress, String.Format(CultureInfo.CurrentCulture, Resources.SignOff.EmailSenderAddress, Branding.CurrentBrand.AppName, pf.UserFullName));
            msg.ReplyToList.Add(maFrom);
            foreach (ClubMember cm in lst)
            {
                msg.To.Add(new MailAddress(cm.Email, cm.UserFullName));
            }
            msg.Subject    = String.Format(CultureInfo.CurrentCulture, Branding.ReBrand(Resources.Club.ContactSubjectTemplate), CurrentClub.Name);
            msg.Body       = txtContact.Text + "\r\n\r\n" + String.Format(CultureInfo.CurrentCulture, Resources.Club.MessageSenderTemplate, pf.UserFullName, pf.Email);
            msg.IsBodyHtml = false;
            util.SendMessage(msg);
        }
        if (ckRequestMembership.Checked)
        {
            foreach (ClubMember admin in lst)
            {
                new CFIStudentMapRequest(Page.User.Identity.Name, admin.Email, CFIStudentMapRequest.RoleType.RoleRequestJoinClub, CurrentClub).Send();
            }
        }

        mpuGuestContact.Hide();
        txtContact.Text             = string.Empty;
        ckRequestMembership.Checked = false;
        lblMessageStatus.Visible    = true;
    }
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                m_sm.ExecuteRequest(m_smr);
                switch (m_smr.Requestedrole)
                {
                case CFIStudentMapRequest.RoleType.RoleCFI:
                case CFIStudentMapRequest.RoleType.RoleStudent:
                    Response.Redirect("~/Member/Training.aspx/" + (m_smr.Requestedrole == CFIStudentMapRequest.RoleType.RoleCFI ? tabID.instStudents.ToString() : tabID.instInstructors.ToString()));
                    break;

                case CFIStudentMapRequest.RoleType.RoleInviteJoinClub:
                {
                    // Let the requestor know that the invitation has been accepted.
                    Profile pfTarget  = Profile.GetUser(m_smr.TargetUser.Contains("@") ? System.Web.Security.Membership.GetUserNameByEmail(m_smr.TargetUser) : m_smr.TargetUser);
                    string  szSubject = String.Format(CultureInfo.CurrentCulture, Resources.Club.AddMemberInvitationAccepted, m_smr.ClubToJoin.Name);
                    string  szBody    = Branding.ReBrand(Resources.Club.ClubInvitationAccepted).Replace("<% ClubName %>", m_smr.ClubToJoin.Name).Replace("<% ClubInvitee %>", pfTarget.UserFullName);
                    foreach (ClubMember cm in ClubMember.AdminsForClub(m_smr.ClubToJoin.ID))
                    {
                        util.NotifyUser(szSubject, szBody.Replace("<% FullName %>", cm.UserFullName), new MailAddress(cm.Email, cm.UserFullName), false, false);
                    }
                    Response.Redirect(String.Format(CultureInfo.InvariantCulture, "~/Member/ClubDetails.aspx/{0}", m_smr.ClubToJoin.ID));
                }
                break;

                case CFIStudentMapRequest.RoleType.RoleRequestJoinClub:
                {
                    // Let the requestor know that the request has been approved.
                    Profile pfRequestor = Profile.GetUser(m_smr.RequestingUser);
                    string  szSubject   = String.Format(CultureInfo.CurrentCulture, Resources.Club.AddMemberRequestAccepted, m_smr.ClubToJoin.Name);
                    string  szBody      = Branding.ReBrand(Resources.Club.ClubRequestAccepted).Replace("<% ClubName %>", m_smr.ClubToJoin.Name).Replace("<% FullName %>", pfRequestor.UserFullName);
                    util.NotifyUser(szSubject, szBody, new MailAddress(pfRequestor.Email, pfRequestor.UserFullName), false, false);
                    Response.Redirect(String.Format(CultureInfo.InvariantCulture, "~/Member/ClubDetails.aspx/{0}", m_smr.ClubToJoin.ID));
                }
                break;
                }
            }
            catch (MyFlightbookValidationException ex)
            {
                pnlReviewRequest.Visible = false;
                lblError.Text            = ex.Message;
                pnlConfirm.Visible       = false;
            }
        }