public DaoEntity <T> Input <T>(DaoEntity <T> daoEntity) where T : EntityObject { var collection = daoEntity.Collection; Dictionary <string, object> colData; if (data.ContainsKey(collection)) { colData = data[collection]; } else { colData = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); data.Add(collection, colData); } if (colData.ContainsKey(daoEntity.Key)) { colData[daoEntity.Key] = daoEntity; } else { colData.Add(daoEntity.Key, daoEntity); } return(daoEntity); }
public DaoEntity <T> Output <T>(string collection, string key) where T : EntityObject { var daoEntity = (T)data[collection][key]; return(DaoEntity.Create(collection, key, daoEntity)); }
/// <summary> /// Creates or Updates the collection specified entirely. /// </summary> /// <param name="replacingCollection">The replacing collection.</param> /// <returns></returns> public IEnumerable <T> Put([FromBody] IEnumerable <T> replacingCollection) { return(this.daoProvider.Input <T>(replacingCollection .Select(o => DaoEntity.Create(this.CollectionName, o)))); }
/// <summary> /// creates a new entity in the specified collection. /// </summary> /// <param name="creating">The creating.</param> /// <returns></returns> public T Post([FromBody] T creating) { var daoEntity = DaoEntity.Create(this.CollectionName, creating); return(this.daoProvider.Input(daoEntity).Data); }
/// <summary> /// Creates or updates the specified entity by key in the collection. /// </summary> /// <param name="key">The key.</param> /// <param name="updating">The updating.</param> /// <returns></returns> public T Put(string key, [FromBody] T updating) { var daoObject = DaoEntity.Create(this.CollectionName, key, updating); return(this.daoProvider.Input <T>(daoObject).Data); }