Guest User

Umbraco Contour GotoPageOnSubmit

a guest
Mar 21st, 2014
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.22 KB | None | 0 0
  1. public class ArrangementPaymentHandler : Umbraco.Forms.Core.WorkflowType
  2.     {
  3.         public override System.Collections.Generic.List<Exception> ValidateSettings()
  4.         {
  5.             var exceptions = new List<Exception>();
  6.             return exceptions;
  7.         }
  8.  
  9.         public ArrangementPaymentHandler()
  10.         {
  11.             this.Name = "Arrangement payment workflow";
  12.             this.Id = new Guid("20584169-2351-4569-8c4c-cf76ddf97dda");
  13.             this.Description = "Arrangement payment workflow til events";
  14.         }
  15.  
  16.         public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
  17.         {
  18.            
  19.             RecordService service = new RecordService(record);
  20.             var lang = library.GetCurrentDomains(Node.GetCurrent().Id)[0].Language.CultureAlias;
  21.            
  22.             #region todo
  23.             //RecordStorage rs = new RecordStorage();
  24.             //var isthere = from r in rs.GetAllRecords(e.Form.Id)
  25.             //              where
  26.             //                  r.GetRecordField("email").ValuesAsString().ToLower().Equals(
  27.             //                      record.GetRecordField("email").ValuesAsString().ToLower())
  28.             //              &&
  29.             //              r.UmbracoPageId.Equals(
  30.             //                     record.UmbracoPageId)
  31.             //                     && r.State == FormState.Approved
  32.             //              select r;
  33.  
  34.             //rs.Dispose();
  35.  
  36.             //if (isthere.Any())
  37.             //{
  38.             //    var dobbleSubmissonPageId = int.Parse(ConfigurationManager.AppSettings["EventDobbleSubmissonPageID"]);
  39.             //    //BUG: LK Recordfield do not get updated when record is not approved ?
  40.             //    record.GetRecordField("Paid").Values.Clear();
  41.             //    record.GetRecordField("Paid").Values.Add("Dobble submisson");
  42.             //    e.Form.GoToPageOnSubmit = dobbleSubmissonPageId;
  43.             //    return WorkflowExecutionStatus.Cancelled;
  44.             //}
  45.             #endregion
  46.  
  47.             Node currentnode = umbraco.NodeFactory.Node.GetCurrent();
  48.             Document umpage = new Document(currentnode.Id);
  49.  
  50.             // Sent to payment if theres a amount
  51.             if (!string.IsNullOrEmpty(umpage.getProperty("eventPrice").Value.ToString()) && umpage.getProperty("eventPrice").Value.ToString() != "0")
  52.             {
  53.                 //dibspaymentsite pageid
  54.                 var paymentPageId = string.Empty;
  55.  
  56.                 if (lang == "da-DK")
  57.                     paymentPageId = ConfigurationManager.AppSettings["danishDibsPaymentPageId"].ToString();
  58.                 else
  59.                     paymentPageId = ConfigurationManager.AppSettings["englishDibsPaymentPageId"].ToString();
  60.                
  61.                 e.Form.GoToPageOnSubmit = int.Parse(paymentPageId);
  62.             }
  63.             else
  64.             {
  65.                 // Move from sumbitted to approved
  66.                 record.GetRecordField("Paid").Values.Clear();
  67.                 record.GetRecordField("Paid").Values.Add("Gratis");
  68.  
  69.                 service.Approve();
  70.             }
  71.            
  72.             service.Dispose();
  73.             return WorkflowExecutionStatus.Completed;
  74.         }
  75.     }
Advertisement
Add Comment
Please, Sign In to add comment