public async Task InsertAsync(OptionalItem item)
 {
     if (item != null)
     {
         await _context.Tbl_OptionalItems.AddAsync(item);
         await SaveChangeAsync();
     }
 }
示例#2
0
 public static bool updateClassProperties(string path)
 {
     if (courseProperties == null)
     {
         courseProperties = new OptionalItem <string, string> [1];
     }
     return(loadOptionalList("GuetModel.Resources.CourseProperties.txt", path, ref courseProperties));
 }
 public void Insert(OptionalItem item)
 {
     if (item != null)
     {
         _context.Tbl_OptionalItems.Add(item);
         SaveChange();
     }
 }
示例#4
0
 public static bool updateMajorList(string path)
 {
     if (majorList == null)
     {
         majorList = new OptionalItem <string, string> [1];
     }
     return(loadOptionalList("GuetModel.Resources.MajorList.txt", path, ref majorList));
 }
 public static string Required(OptionalItem item)
 {
     if (string.IsNullOrWhiteSpace(item.GetValue()))
     {
         return(item.Label + " is required");
     }
     return(null);
 }
示例#6
0
 private static OptionalItem <string, string>[] loadGrades(int fromYear, int toYear)
 {
     OptionalItem <string, string>[] grades = new OptionalItem <string, string> [toYear - fromYear + 1];
     for (int i = 0; i < grades.Length; i++)
     {
         string year = (fromYear + i).ToString();
         grades[i] = new OptionalItem <string, string>(year, year);
     }
     return(grades);
 }
 public async Task <IActionResult> AddRequest(OptionalItem model)
 {
     if (ModelState.IsValid)
     {
         var item = new OptionalItem()
         {
             ID            = model.ID,
             AttachFileURL = model.AttachFileURL,
             Customer      = model.Customer,
             CustomerID    = model.CustomerID,
             Description   = model.Description,
             Details       = model.Details
         };
     }
     return(null);
 }
        protected void SubmitForm(object sender, EventArgs e)
        {
            //var subject = Request.Form["ctl00$MasterMainContent$EmailForm$EmailFormSubject"];
            var subject = EmailFormSubject.Value;

            if (subject == "Other")
            {
                subject = EmailFormOtherSubject.Text;
            }
            // validate the Captcha to check we're not dealing with a bot
            if (IsHuman)
            {
                try
                {
                    if (!Validation.IsValidEmailAddress(EmailFormFromEmailAddress.Text))
                    {
                        throw new VoteException("The email address you entered is not valid");
                    }
                    if (string.IsNullOrWhiteSpace(subject))
                    {
                        throw new VoteException(
                                  "Please select a subject for the email");
                    }
                    if (!MessageOptional && string.IsNullOrWhiteSpace(EmailFormMessage.Text))
                    {
                        throw new VoteException("The email message body is missing");
                    }

                    OptionalItem.ValidateAll(_OptionalItems);

                    if (Callback != null)
                    {
                        // create dictionary for callback
                        var dict = new Dictionary <string, string>
                        {
                            // add the fixed items
                            { "EmailFormSubject", subject },
                            { "EmailFormFromEmailAddress", EmailFormFromEmailAddress.Text },
                            { "EmailFormMessage", EmailFormMessage.Text }
                        };

                        // add any optional items
                        OptionalItem.AddAllToDictionary(_OptionalItems, dict);

                        Callback(dict);
                    }

                    var email = new MailMessage
                    {
                        IsBodyHtml = false,
                        //From = new MailAddress(EmailFormFromEmailAddress.Text)
                        From = new MailAddress("*****@*****.**")
                    };
                    email.To.Add(ToEmailAddress);
                    if (!string.IsNullOrWhiteSpace(CcEmailAddress))
                    {
                        email.CC.Add(CcEmailAddress);
                    }
                    email.Subject = subject;
                    email.Body    = "Email: " + EmailFormFromEmailAddress.Text + "\n\n" +
                                    OptionalItem.FormatAll(_OptionalItems) + EmailFormMessage.Text;

#if !NoEmail
                    EmailUtility.GetConfiguredSmtpClient().Send(email);
#endif
                    EmailFormGoodLabel.Text    = "Email has been sent";
                    EmailFormGoodLabel.Visible = true;

                    EmailFormSubject.Value         = string.Empty;
                    EmailFormOtherSubject.Text     = string.Empty;
                    EmailFormFromEmailAddress.Text = string.Empty;
                    EmailFormMessage.Text          = string.Empty;
                    OptionalItem.ClearAll(_OptionalItems);
                }
                catch (Exception ex)
                {
                    EmailFormErrorLabel.Text    = ex.Message;
                    EmailFormErrorLabel.Visible = true;
                }
            }
            else
            {
                EmailFormErrorLabel.Text    = "The typed characters did not match the picture";
                EmailFormErrorLabel.Visible = true;
            }
            EmailFormCaptchaCodeTextBox.Text = null; // clear previous user input
        }