/// <summary> /// Submit event handler for the WebFormUserControl that renders this control. /// </summary> /// <param name="control">Calling user control</param> /// <param name="e">Event arguments</param> /// <returns></returns> public virtual WebFormSubmitEventArgs Submit(WebFormUserControl control, WebFormSubmitEventArgs e) { if (control == null || e == null) { return(e); } var context = PortalCrmConfigurationManager.CreateServiceContext(PortalName); if (control.CurrentStepEntityID != Guid.Empty) { // Update existing entity var sourceEntity = new Entity(control.CurrentStepEntityLogicalName) { Id = control.CurrentStepEntityID }; sourceEntity["adx_prepaidincidentscurrentlyavailable"] = PrepaidIncidentsAvailable < 0 ? 0 : PrepaidIncidentsAvailable; sourceEntity["adx_prepaidincidentsrequired"] = PrepaidIncidentsRequired < 0 ? 0 : PrepaidIncidentsRequired; if (SupportPlanID != Guid.Empty) { sourceEntity["adx_supportplan"] = new EntityReference("adx_supportplan", SupportPlanID); } else { sourceEntity["adx_paymentrequired"] = true; } if (Customer != null && Customer.LogicalName == "account") { sourceEntity["adx_customer"] = new EntityReference("account", Customer.Id); } context.Attach(sourceEntity); context.UpdateObject(sourceEntity); context.SaveChanges(); } else { var sourceEntity = new Entity(control.CurrentStepEntityLogicalName); sourceEntity["adx_prepaidincidentscurrentlyavailable"] = PrepaidIncidentsAvailable < 0 ? 0 : PrepaidIncidentsAvailable; sourceEntity["adx_prepaidincidentsrequired"] = PrepaidIncidentsRequired < 0 ? 0 : PrepaidIncidentsRequired; if (SupportPlanID != Guid.Empty) { sourceEntity["adx_supportplan"] = new EntityReference("adx_supportplan", SupportPlanID); } else { sourceEntity["adx_paymentrequired"] = true; } if (Customer != null && Customer.LogicalName == "account") { sourceEntity["adx_customer"] = new EntityReference("account", Customer.Id); } context.AddObject(sourceEntity); context.SaveChanges(); e.EntityID = sourceEntity.Id; } return(e); }
protected override void OnSubmit(object sender, WebFormSubmitEventArgs e) { var serviceRequestId = SelectedServiceRequestId.Value; if (!string.IsNullOrWhiteSpace(serviceRequestId)) { var entityId = new Guid(serviceRequestId); var context = PortalCrmConfigurationManager.CreateServiceContext(); var type = GetServiceRequestType(context); var duplicateStatusFieldName = type.GetAttributeValue <string>("adx_duplicatestatusfieldname"); var duplicateParentFieldName = type.GetAttributeValue <string>("adx_duplicateparentfieldname"); if (!string.IsNullOrWhiteSpace(duplicateStatusFieldName) || !string.IsNullOrWhiteSpace(duplicateParentFieldName)) { var duplicateStatus = entityId == PreviousStepEntityID ? DuplicateStatus.Potential : DuplicateStatus.Confirmed; var duplicateParent = entityId == PreviousStepEntityID ? null : new EntityReference(PreviousStepEntityLogicalName, entityId); var entity = GetPreviousStepEntity(context); if (!string.IsNullOrWhiteSpace(duplicateStatusFieldName)) { entity.SetAttributeValue(duplicateStatusFieldName, new OptionSetValue((int)duplicateStatus)); } if (!string.IsNullOrWhiteSpace(duplicateParentFieldName)) { entity.SetAttributeValue(duplicateParentFieldName, duplicateParent); } context.UpdateObject(entity); context.SaveChanges(); } e.EntityID = entityId; return; } if (!_isUnique) { e.Cancel = true; } }
protected override void OnSubmit(object sender, WebFormSubmitEventArgs e) { if (Purchasable == null) { e.Cancel = true; PurchaseSummary.Visible = false; GeneralErrorMessage.Visible = true; WebForm.EnableDisableNextButton(false); return; } WebForm.CurrentSessionHistory.QuoteId = Purchasable.Quote.Id; Page.Validate(); if (!Page.IsValid) { e.Cancel = true; return; } if (Purchasable.RequiresShipping) { var dataAdapter = CreatePurchaseDataAdapter(Target, CurrentStepEntityPrimaryKeyLogicalName); dataAdapter.UpdateShipToAddress(new PurchaseAddress { City = ShippingCity.Text, Country = ShippingCountry.Text, Line1 = ShippingAddressLine1.Text, Line2 = ShippingAddressLine2.Text, Name = ShippingName.Text, PostalCode = ShippingPostalCode.Text, StateOrProvince = ShippingStateProvince.Text }); } SetAttributeValuesAndSave(); }
protected override void OnSubmit(object sender, WebFormSubmitEventArgs e) { if (!IsPaymentPaypal || Paid) { return; } if (Purchasable == null) { throw new InvalidOperationException("Unable to retrieve purchase information."); } var total = Purchasable.TotalAmount; if (total < 0) { throw new InvalidOperationException("Unable to retrieve valid purchase total value."); } HandlePaypalPayment(total); }
protected internal virtual void OnSubmit(object sender, WebFormSubmitEventArgs e) { // Set e.Cancel = true; to prevent web form from proceeding. // Set e.EntityLogicalName, e.EntityPrimaryKeyLogicalName, e.EntityID with the values of the created record. }
protected override void OnSubmit(object sender, WebFormSubmitEventArgs e) { e = CaseEntitlementControl.Submit(this, e); }