Exemplo n.º 1
0
        public async Task <SResponse <List <Product> > > AddNewProduct(Product newProduct)
        {
            SResponse <List <Product> > serviceResponse = new SResponse <List <Product> >();

            List <Product> dbProduct = await _greencontext.Products.ToListAsync();


            //  newProduct.User = await_greencontext.Products.FindAsync(newProduct.User.Id);

            await _greencontext.Products.AddAsync(newProduct);

            await _greencontext.SaveChangesAsync();

            serviceResponse.Data = dbProduct;
            return(serviceResponse);
        }
Exemplo n.º 2
0
        public async Task <SResponse <List <Category> > > AddNewCategory(Category newCategory)
        {
            SResponse <List <Category> > serviceResponse = new SResponse <List <Category> >();

            List <Category> dbCategory = await _greencontext.Categories.ToListAsync();


            //  newProduct.User = await_greencontext.Products.FindAsync(newProduct.User.Id);

            await _greencontext.Categories.AddAsync(newCategory);

            await _greencontext.SaveChangesAsync();

            serviceResponse.Data = dbCategory;
            return(serviceResponse);
        }