コード例 #1
0
 protected void btnSubmitQuiz_Click(object sender, EventArgs e)
 {
     try
     {
         //validate application by email address
         bool valid = VolunteerApplication.Validate(txtEmail.Text);
         if (!valid)
         {
             QuizFailed("You have been applied recently. Please try again in 6 months time form the previously applied date.");
         }
         else
         {
             //calculate score
             int score = CalculateScore();
             if (score == 5)
             {
                 QuizPassed();
             }
             else
             {
                 VolunteerApplication.UpdateFailedAttempt(txtEmail.Text);
                 QuizFailed("Sorry you do not meet our volunteering requirements. Please try again in 6 months time.");
             }
         }
     }
     catch (Exception ex)
     {
         ShowMessage("Unknown Error! Please try again later.");
     }
 }
コード例 #2
0
 private void BindVolunteerApplicationData()
 {
     lstGrid.DataSource = VolunteerApplication.GetVolunteerApplication(true);
     lstGrid.DataBind();
     lstGridPast.DataSource = VolunteerApplication.GetVolunteerApplication(false);
     lstGridPast.DataBind();
 }
コード例 #3
0
        protected void btnSubmitApplication_Click(object sender, EventArgs e)
        {
            try
            {
                //create object
                VolunteerApplication volunteerApplication = new VolunteerApplication();
                volunteerApplication.VolunteerName   = txtName.Text;
                volunteerApplication.ApplicationDate = DateTime.Now;
                volunteerApplication.Availability    = Convert.ToInt32(ddlAvailability.SelectedValue);
                volunteerApplication.PreferredUnit   = Convert.ToInt32(ddlPreferredUnit.SelectedValue);
                volunteerApplication.Status          = 1;
                volunteerApplication.ContactNumber   = txtContactNumber.Text;
                volunteerApplication.EmailAddress    = txtEmail.Text;
                VolunteerApplication.SaveVolunteerApplication(volunteerApplication);

                //send email
                string message   = "Thank you for applying. We will be in touch with you shortly.";
                string emailBody = Email.PopulateBody(volunteerApplication.VolunteerName.Split(' ')[0], message);
                Email.SendEmail(volunteerApplication.EmailAddress, "Volunteer Application", emailBody);

                ShowMessage("Application Submitted!");
                ClearAll();
            }
            catch (Exception ex)
            {
                ShowMessage("Application Submission Failed!");
            }
            finally
            {
                panelBody.Visible  = false;
                panelPopup.Visible = false;
            }
        }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            VolunteerApplication volunteerApplication = db.VolunteerApplications.Find(id);

            db.VolunteerApplications.Remove(volunteerApplication);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "VolunteerID,Name,Address,City,Email,ContactNumber,Language,WhyInterested,PastVolunteer,OpportunityID")] VolunteerApplication volunteerApplication)
 {
     if (ModelState.IsValid)
     {
         db.Entry(volunteerApplication).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OpportunityID = new SelectList(db.VolunteerOpportunities, "OpportunityID", "OpportunityName", volunteerApplication.OpportunityID);
     return(View(volunteerApplication));
 }
コード例 #6
0
        // GET: VolunteerApplication/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VolunteerApplication volunteerApplication = db.VolunteerApplications.Find(id);

            if (volunteerApplication == null)
            {
                return(HttpNotFound());
            }
            return(View(volunteerApplication));
        }
コード例 #7
0
        // GET: VolunteerApplication/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VolunteerApplication volunteerApplication = db.VolunteerApplications.Find(id);

            if (volunteerApplication == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OpportunityID = new SelectList(db.VolunteerOpportunities, "OpportunityID", "OpportunityName", volunteerApplication.OpportunityID);
            return(View(volunteerApplication));
        }
コード例 #8
0
        protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            //https://www.c-sharpcorner.com/UploadFile/1326ef/transactionscope-in-C-Sharp/
            using (TransactionScope transactionScope = new TransactionScope())
            {
                try
                {
                    Models.Admin admin                  = (Models.Admin)Session["Admin"];
                    DropDownList dropDownList           = sender as DropDownList;
                    int          selectedValue          = Convert.ToInt32(dropDownList.SelectedItem.Value);
                    int          volunteerApplicationID = Convert.ToInt32(dropDownList.Attributes["volunteerApplicationID"]);
                    VolunteerApplication.UpdateVolunteerApplicationStatus(volunteerApplicationID, selectedValue, admin.AdminID);
                    VolunteerApplication.SendEmailToApplicant(volunteerApplicationID, selectedValue);
                    transactionScope.Complete();
                    transactionScope.Dispose();

                    BindVolunteerApplicationData();
                }
                catch (Exception ex)
                {
                    transactionScope.Dispose();
                }
            }
        }