Ejemplo n.º 1
0
        public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
        {
            // first we log it
            Umbraco.Core.Logging.LogHelper.Info(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "the IP " + record.IP + " has submitted a record");
            // we can then iterate through the fields

            var refundApplication = new RefundApplication();

            foreach (RecordField rf in record.RecordFields.Values)
            {
                // and we can then do something with the collection of values on each field
                List<object> vals = rf.Values;
                switch (rf.Alias)
                {
                    case "title":
                        refundApplication.Title = (string)rf.Values.FirstOrDefault();
                        break;
                    case "irdNumber":
                        refundApplication.IRDNumber = (string)rf.Values.FirstOrDefault();
                        break;
                    case "firstName":
                        refundApplication.FirstName = (string)rf.Values.FirstOrDefault();
                        break;
                    case "lastName":
                        refundApplication.LastName = (string)rf.Values.FirstOrDefault();
                        break;
                    case "emailAddress":
                        refundApplication.Email = (string)rf.Values.FirstOrDefault();
                        break;
                }

                UpdateRecord(refundApplication);

                // or just get it as a string
                //rf.ValuesAsString();
            }

            //// If we altered a field, we can save it using the record storage
            //RecordStorage store = new RecordStorage();
            //store.UpdateRecord(record, e.Form);
            //store.Dispose();

            //// we then invoke the recordservice which handles all record states //and make the service delete the record.
            //RecordService rs = new RecordService();
            //rs.Delete(record, e.Form);
            ////rs.Dispose(record, e.Form);

            return WorkflowExecutionStatus.Completed;
        }
        public async Task<ActionResult> Submit(RefundApplication refundApplication)
        {
            var home = Umbraco.TypedContentAtRoot().First();
            var settings = Umbraco.TypedContent(1091);

            var email = home.GetProperty("mailTo").Value.ToString();
            var emailFrom = settings.GetProperty("fromEmail").Value.ToString();
            var smtpServer = settings.GetProperty("smtpServer").Value.ToString();
            var smtpUsername = settings.GetProperty("smtpUsername").Value.ToString();
            var smtpPassword = settings.GetProperty("smtpPassword").Value.ToString();

            refundApplication.ApplicationDate = SetDateForMongo(DateTime.Now);
            var refundApplicationRepository = new RefundApplicationRepository();
            await refundApplicationRepository.CreateSync(refundApplication);

            var mailService = new MailService();
            mailService.Send(email, Server.MapPath("~/RegistrationNotification.html"), "", refundApplication, smtpServer, smtpUsername, smtpPassword, emailFrom);

            return Json(new { success = true, responseText = "Added." }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 3
0
        public void Send(string to, string templatePath, string username, RefundApplication refundApplication, string smtpServer, string smtpUsername, string smtpPassword, string fromEmail)
        {
            MailMessage mail = new MailMessage();
            SmtpClient client = new SmtpClient();
            client.Port = 25;
            client.EnableSsl = true;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Host = smtpServer;

            //mail.To.Add(new MailAddress(to));

            mail.To.Add(new MailAddress(to));
            mail.From = new MailAddress(fromEmail);
            mail.Subject = "iRefund Application";
            mail.IsBodyHtml = true;
            var param = new string[] { refundApplication.IRDNumber, refundApplication.Title, refundApplication.FirstName, refundApplication.MiddleName, refundApplication.LastName, refundApplication.DateOfBirth, refundApplication.Email, refundApplication.DayTimePhone, refundApplication.MobilePhone, refundApplication.HowYouHeard, refundApplication.HaveNZDriverLicense, refundApplication.DriverLicenseNumber, refundApplication.CardVersion };
            mail.Body = GetMessage(param, templatePath);
            client.UseDefaultCredentials = true;
            client.Credentials = new NetworkCredential(smtpUsername, smtpPassword);
            var userToken = "something";
            client.Send(mail);
        }
Ejemplo n.º 4
0
        private async Task<bool> UpdateRecord(RefundApplication refundApplication)
        {
            var refundApplicationRepo = new RefundApplicationRepository();
            return await refundApplicationRepo.Update(refundApplication.IRDNumber, refundApplication.Title, refundApplication.FirstName, refundApplication.LastName, refundApplication.Email);

        }
Ejemplo n.º 5
0
 public async Task<ActionResult> Register(string username, string password)
 {
     var refundAppRepo = new RefundApplicationRepository();
     var existing = await refundAppRepo.FindIRD(username);
     if (existing.Count == 0)
     {
         var refunApp = new RefundApplication
         {
             IRDNumber = username,
             Password = password
         };
         await refundAppRepo.CreateSync(refunApp);
         Session["IRDNumber"] = username;
         Response.StatusCode = (int)HttpStatusCode.OK;
         return Json(new { success = true, responseText = "Added." }, JsonRequestBehavior.AllowGet);
     }
     else
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return Json(new { success = false, responseText = "User already exist." }, JsonRequestBehavior.AllowGet);
     }
 }