Пример #1
0
        public static async Task <ActionResult <T> > Add <T, TKey>(this Controller controller, ICRUDService <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)));
        }
Пример #2
0
        public static async Task <ActionResult <IEnumerable <UriAndValue <T> > > > Add <T, TKey>(this Controller controller, ICRUDService <T, TKey> manager, IEnumerable <T> values)
            where T : class where TKey : IComparable
        {
            IEnumerable <TKey> newids = await manager.Add(values);

            IEnumerable <T> 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(controller.Ok(newuris));
        }
Пример #3
0
 public T Insert(TInsert obj)
 {
     return(CRUDservis.Add(obj));
 }
Пример #4
0
 public IActionResult add(Product product)
 {
     _ProductService.Add(product);
     return RedirectToAction("Index");
 }