Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ArrangementPaymentHandler : Umbraco.Forms.Core.WorkflowType
- {
- public override System.Collections.Generic.List<Exception> ValidateSettings()
- {
- var exceptions = new List<Exception>();
- return exceptions;
- }
- public ArrangementPaymentHandler()
- {
- this.Name = "Arrangement payment workflow";
- this.Id = new Guid("20584169-2351-4569-8c4c-cf76ddf97dda");
- this.Description = "Arrangement payment workflow til events";
- }
- public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
- {
- RecordService service = new RecordService(record);
- var lang = library.GetCurrentDomains(Node.GetCurrent().Id)[0].Language.CultureAlias;
- #region todo
- //RecordStorage rs = new RecordStorage();
- //var isthere = from r in rs.GetAllRecords(e.Form.Id)
- // where
- // r.GetRecordField("email").ValuesAsString().ToLower().Equals(
- // record.GetRecordField("email").ValuesAsString().ToLower())
- // &&
- // r.UmbracoPageId.Equals(
- // record.UmbracoPageId)
- // && r.State == FormState.Approved
- // select r;
- //rs.Dispose();
- //if (isthere.Any())
- //{
- // var dobbleSubmissonPageId = int.Parse(ConfigurationManager.AppSettings["EventDobbleSubmissonPageID"]);
- // //BUG: LK Recordfield do not get updated when record is not approved ?
- // record.GetRecordField("Paid").Values.Clear();
- // record.GetRecordField("Paid").Values.Add("Dobble submisson");
- // e.Form.GoToPageOnSubmit = dobbleSubmissonPageId;
- // return WorkflowExecutionStatus.Cancelled;
- //}
- #endregion
- Node currentnode = umbraco.NodeFactory.Node.GetCurrent();
- Document umpage = new Document(currentnode.Id);
- // Sent to payment if theres a amount
- if (!string.IsNullOrEmpty(umpage.getProperty("eventPrice").Value.ToString()) && umpage.getProperty("eventPrice").Value.ToString() != "0")
- {
- //dibspaymentsite pageid
- var paymentPageId = string.Empty;
- if (lang == "da-DK")
- paymentPageId = ConfigurationManager.AppSettings["danishDibsPaymentPageId"].ToString();
- else
- paymentPageId = ConfigurationManager.AppSettings["englishDibsPaymentPageId"].ToString();
- e.Form.GoToPageOnSubmit = int.Parse(paymentPageId);
- }
- else
- {
- // Move from sumbitted to approved
- record.GetRecordField("Paid").Values.Clear();
- record.GetRecordField("Paid").Values.Add("Gratis");
- service.Approve();
- }
- service.Dispose();
- return WorkflowExecutionStatus.Completed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment