Esempio n. 1
0
        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)));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public async Task <T> Get(TKey id)
 {
     return(await _manager.Get(id));
 }