Uniconta Copy Entity from/to JSON

Date: 2021-08-06
public class JsonTableDataModel
{
	public int TableNo { get; set; }
	public int CompanyId { get; set; }
	public int RowId { get; set; }
	public int MasterTableId { get; set; }
	public int MasterRow { get; set; }
	public Type MasterType { get; set; }
	public string KeyStr { get; set; }
	public string KeyName { get; set; }
	public byte AttachmentFlags { get; set; }
	public byte[] CustomFields { get; set; }
	public object[] UserFields { get; set; }
}

// using Uniconta.DataModel;
public abstract class ExtendedTableData : TableDataWithKeyUser
{
	public JsonTableDataModel GetJsonModel()
	{
		if (userFields == null)
		{
			userFields = new TableFieldDataRow(_CustomFields, _CompanyId, UserFieldTableId());
			_CustomFields = null;
		}

		return new JsonTableDataModel()
		{
			TableNo = _TableNo,
			CompanyId = _CompanyId,
			RowId = _RowId,
			MasterTableId = _MasterTableId,
			MasterRow = _MasterRow,
			MasterType = _MasterType,
			KeyStr = _KeyStr,
			KeyName = _KeyName,
			AttachmentFlags = AttachmentFlags,
			CustomFields = _CustomFields,
			UserFields = userFields?._data
		};
	}

	public void FromJsonModel(JsonTableDataModel model)
	{
		_TableNo = model.TableNo;
		_CompanyId = model.CompanyId;
		_RowId = model.RowId;
		_MasterTableId = model.MasterTableId;
		_MasterRow = model.MasterRow;
		_MasterType = model.MasterType;
		_KeyStr = model.KeyStr;
		_KeyName = model.KeyName;
		AttachmentFlags = model.AttachmentFlags;
		_CustomFields = model.CustomFields;
		SetUserFields(model.UserFields);
	}
}
52480cookie-checkUniconta Copy Entity from/to JSON