/// <summary> /// /// </summary> /// <param name="forceToAdd"></param> /// <param name="sourceFld"></param> /// <returns></returns> public long SaveField(AWAPI_Data.Data.awContentCustomField sourceFld) { awContentCustomField fld = null; bool addNew = false; if (sourceFld == null) { return(0); } if (sourceFld.customFieldId > 0) { fld = GetField(sourceFld.customFieldId); } if (fld == null) { fld = new awContentCustomField(); if (sourceFld.contentId <= 0 || sourceFld.userId <= 0) { throw new Exception("Content Id and User Id must be set in order the create a new custom field"); } addNew = true; fld.customFieldId = AWAPI_Common.library.MiscLibrary.CreateUniqueId(); fld.contentId = sourceFld.contentId; fld.createDate = DateTime.Now; } fld.title = sourceFld.title; fld.description = sourceFld.description; fld.applyToSubContents = sourceFld.applyToSubContents; fld.fieldType = sourceFld.fieldType; fld.maximumLength = sourceFld.maximumLength; fld.maximumValue = sourceFld.maximumValue; fld.minimumValue = sourceFld.minimumValue; fld.defaultValue = sourceFld.defaultValue; fld.regularExpression = sourceFld.regularExpression; fld.sortOrder = sourceFld.sortOrder; fld.isEnabled = sourceFld.isEnabled; fld.userId = sourceFld.userId; fld.lastBuildDate = DateTime.Now; if (addNew) { _context.awContentCustomFields.InsertOnSubmit(fld); } _context.SubmitChanges(); if (addNew && !fld.isEnabled) { new ContentFormLibrary().RemoveCustomField(fld.customFieldId); } return(fld.customFieldId); }
/// <summary> /// /// </summary> /// <param name="fld"></param> /// <returns></returns> public long SaveField(awContentCustomField fld) { return(_contentCustomField.SaveField(fld)); }