2020-10-14 01:24:27 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
|
|
|
|
|
namespace COA.EnterpriseServices.DataAccess.QuickBase
|
|
|
|
|
{
|
2020-10-14 12:35:14 +00:00
|
|
|
|
public class QuickBaseDataAccess<T> : IDataAccess<T> where T : class, IRecord, new()
|
2020-10-14 01:24:27 +00:00
|
|
|
|
{
|
|
|
|
|
public bool Add(T item)
|
|
|
|
|
{
|
2020-10-14 12:35:14 +00:00
|
|
|
|
var fieldData = GetFieldData(item);
|
|
|
|
|
|
|
|
|
|
// use fieldData to create mapped data to push to quickbase API
|
|
|
|
|
|
2020-10-14 03:10:25 +00:00
|
|
|
|
return true;
|
2020-10-14 01:24:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Update(T item)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-14 12:35:14 +00:00
|
|
|
|
public T Get(int id)
|
2020-10-14 01:24:27 +00:00
|
|
|
|
{
|
2020-10-14 12:35:14 +00:00
|
|
|
|
// we'll never get data from QB
|
|
|
|
|
return null;
|
2020-10-14 01:24:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ICollection<T> Get(Expression<Func<T, bool>> query)
|
|
|
|
|
{
|
2020-10-14 12:35:14 +00:00
|
|
|
|
// we'll never get data from QB
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<KeyValuePair<int, object>> GetFieldData(T item)
|
|
|
|
|
{
|
|
|
|
|
var properties = item.GetType().GetProperties();
|
|
|
|
|
|
|
|
|
|
foreach (var property in properties)
|
|
|
|
|
{
|
|
|
|
|
var fieldId = FieldMapRegistry.GetFieldId(property);
|
|
|
|
|
var value = property.GetValue(item);
|
|
|
|
|
|
|
|
|
|
if (fieldId != null)
|
|
|
|
|
{
|
|
|
|
|
yield return new KeyValuePair<int, object>(fieldId.Value, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-14 01:24:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|