public static async Task <ActionResult <T> > Add <T, TKey>(this Controller controller, ICRUDManager <T, TKey> manager, T value) where T : class where TKey : IComparable { TKey newId = await manager.Add(value); string newUri = controller.GetCurrentUri() + "/" + newId; return(controller.Created(newUri, await manager.Get(newId))); }
public static async Task <IEnumerable <UriAndValue <T> > > AddIntern <T, TKey>(this Controller controller, ICRUDManager <T, TKey> manager, IEnumerable <T> values) where T : class where TKey : IComparable { var newIds = await manager.Add(values); var newObjects = await manager.Get(newIds); string uri = controller.GetCurrentUri("/bulk"); var newUris = newIds.Select(id => uri + "/" + id); var results = newIds.Select((id, idx) => new UriAndValue <T>() { Uri = uri + "/" + id, Value = newObjects.ElementAt(idx) }); return(results); }
public async Task <T> Get(TKey id) { return(await _manager.Get(id)); }