Beispiel #1
0
 protected void btnAddStudent_Click(object sender, EventArgs e)
 {
     if (!Page.IsValid)
     {
         return;
     }
     try
     {
         Profile pf = Profile.GetUser(Page.User.Identity.Name);
         if (String.IsNullOrEmpty(pf.Certificate) && !String.IsNullOrEmpty(txtCertificate.Text))
         {
             pf.Certificate           = txtCertificate.Text.LimitTo(30);
             pf.CertificateExpiration = mfbTypeInDateCFIExpiration.Date;
             pf.FCommit();
         }
         CFIStudentMapRequest smr = m_sm.GetRequest(CFIStudentMapRequest.RoleType.RoleStudent, txtStudentEmail.Text);
         smr.Send();
         lblAddStudentSuccess.Text     = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EditProfileRequestHasBeenSent, HttpUtility.HtmlEncode(txtStudentEmail.Text));
         lblAddStudentSuccess.CssClass = "success";
         txtStudentEmail.Text          = "";
     }
     catch (MyFlightbookException ex)
     {
         lblAddStudentSuccess.Text     = ex.Message;
         lblAddStudentSuccess.CssClass = "error";
     }
 }
 protected void btnAddStudent_Click(object sender, EventArgs e)
 {
     if (!Page.IsValid)
     {
         return;
     }
     try
     {
         CFIStudentMapRequest smr = m_sm.GetRequest(CFIStudentMapRequest.RoleType.RoleStudent, txtStudentEmail.Text);
         smr.Send();
         lblAddStudentSuccess.Text     = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EditProfileRequestHasBeenSent, HttpUtility.HtmlEncode(txtStudentEmail.Text));
         lblAddStudentSuccess.CssClass = "success";
         txtStudentEmail.Text          = "";
     }
     catch (MyFlightbookException ex)
     {
         lblAddStudentSuccess.Text     = ex.Message;
         lblAddStudentSuccess.CssClass = "error";
     }
 }
Beispiel #3
0
    protected void wzRequestSigs_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        IEnumerable <LogbookEntry> lstFlights = SelectedFlights;

        string szCFIUsername = String.Empty;
        string szCFIEmail    = String.Empty;

        MyFlightbook.Profile pfCFI = null;


        bool fIsNewCFI = String.IsNullOrEmpty(cmbInstructors.SelectedValue);

        // Check In case the named email is already an instructor.
        CFIStudentMap sm = new CFIStudentMap(User.Identity.Name);

        if (fIsNewCFI && sm.IsStudentOf(txtCFIEmail.Text))
        {
            fIsNewCFI = false;
            foreach (InstructorStudent inst in sm.Instructors)
            {
                if (String.Compare(inst.Email, txtCFIEmail.Text, StringComparison.CurrentCultureIgnoreCase) == 0)
                {
                    pfCFI = inst;
                    break;
                }
            }
        }
        else
        {
            pfCFI = MyFlightbook.Profile.GetUser(cmbInstructors.SelectedValue);
        }

        if (fIsNewCFI)
        {
            szCFIEmail = txtCFIEmail.Text;
        }
        else
        {
            szCFIUsername = pfCFI.UserName;
        }

        // check if we already know the email

        foreach (LogbookEntry le in lstFlights)
        {
            le.RequestSignature(szCFIUsername, szCFIEmail);
        }

        // Now send the email
        if (fIsNewCFI)
        {
            CFIStudentMapRequest smr = sm.GetRequest(CFIStudentMapRequest.RoleType.RoleCFI, szCFIEmail);
            smr.Send();
        }
        else
        {
            Profile pf = MyFlightbook.Profile.GetUser(User.Identity.Name);
            using (MailMessage msg = new MailMessage())
            {
                msg.From = new MailAddress(Branding.CurrentBrand.EmailAddress, String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.SignOff.EmailSenderAddress, Branding.CurrentBrand.AppName, pf.UserFullName));
                msg.ReplyToList.Add(new MailAddress(pf.Email, pf.UserFullName));
                msg.To.Add(new MailAddress(pfCFI.Email, pfCFI.UserFullName));
                msg.Subject = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.SignOff.SignRequestSubject, pf.UserFullName, Branding.CurrentBrand.AppName);

                string szURL = String.Format(System.Globalization.CultureInfo.InvariantCulture, "https://{0}{1}/{2}", Request.Url.Host, ResolveUrl("~/Member/Training.aspx"), tabID.instStudents.ToString());

                msg.Body = Branding.ReBrand(Resources.SignOff.SignInvitationExisting).Replace("<% SignPendingFlightsLink %>", szURL).Replace("<% Requestor %>", pf.UserFullName);
                util.SendMessage(msg);
            }
        }

        Response.Redirect(String.Format(System.Globalization.CultureInfo.InvariantCulture, "~/Member/Training.aspx/{0}", tabID.instSignFlights));
    }