protected virtual IWizardContentField InitNewWizardField(IWizardContentField o) { switch (o.FieldType) { case nameof(WizardFieldTypes.EMBED): case nameof(WizardFieldTypes.FORM): return(new WizardContentField(new { o.Id, o.GroupKey, o.FieldKey, o.FieldType, FieldData = "{useCardLayout:1}", FieldClass = "row mx-n2", o.ParentKey, o.DefaultLabel, o.Label, WrapperClass = "col card card-border mb-3 px-0", o.WrapperHtmlStart, o.WrapperHtmlEnd, o.AuditChangeType, o.AuditChangeBy, o.AuditChangeDate, o.GroupFilter, o.Order })); } return(o); }
/// <summary> /// Initializes a new instance of the <see cref="WizardButtonData"/> class. /// </summary> /// <param name="data">The data.</param> /// TODO Edit XML Comment Template for #ctor public WizardButtonData(IWizardContentField data) : base(data) { Label = data?.Label ?? ""; Class = data?.FieldClass ?? ""; Wrapper = data?.WrapperClass ?? ""; string strInput = data?.FieldData?.Trim() ?? "{}"; if (string.IsNullOrWhiteSpace(strInput)) { return; } if (strInput.StartsWith("{") && strInput.EndsWith("}")) { try { var jObj = JToken.Parse(strInput); Icon = jObj["icon"]?.ToString() ?? ""; Action = jObj["action"] ?? ""; } catch { // Do Nothing } } }
public virtual object SaveField(WizardField o) { var bResult = false; o.AuditChangeBy = User.Identity.Name; //o.GroupFilter = _groupFilter; IWizardContentField field = o; if (field.Id < 1) { field = InitNewWizardField(field); } if (!_unlockApi) { return(JToken.FromObject(new ApiStatusMessage("You do not have permissions to perform that action", "Permissions Denied", ApiMessageType.Alert))); } ILocalizedContentField oResult = null; try { oResult = _fieldRepository.SaveRecord(new Data.LocalizedContent.LocalizedContentField(field)); bResult = oResult != null; } catch (Exception ex) { return(JToken.FromObject(new ApiExceptionMessage("An error has occurred", ex))); } if (bResult == true) { return(JToken.FromObject(new ApiObjectMessage(oResult, "Record has been saved successfully.", "Record Saved", ApiMessageType.Success))); } // Else return(JToken.FromObject(new ApiStatusMessage("Unable to save record. Please check the data and try again.", "Error while saving", ApiMessageType.Danger))); }