public async Task <IActionResult> PutCustomer(int id, Customer customer)
        {
            if (id != customer.Id)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <T> UpdateAsync(T entity)
        {
            context.Entry(entity).State = EntityState.Modified;
            await context.SaveChangesAsync().ConfigureAwait(false);

            return(entity);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutShoppingDetails([FromRoute] int id, [FromBody] ShoppingDetails shoppingDetails)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != shoppingDetails.ShopId)
            {
                return(BadRequest());
            }

            _context.Entry(shoppingDetails).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ShoppingDetailsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PutProduct(int id, Product product)
        {
            if (id != product.Id)
            {
                return(BadRequest());
            }

            _context.Entry(product).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PutSales(int id, Saless saless)
        {
            if (id != saless.Id)
            {
                return(BadRequest());
            }

            var sales = new Sales();

            List <Customer> cList = await _context.Customer.ToListAsync();

            List <Store> stList = await _context.Store.ToListAsync();

            List <Product> pList = await _context.Product.ToListAsync();

            sales.Id       = id;
            sales.DateSold = Convert.ToDateTime(saless.DateSold);

            foreach (var customer in cList)
            {
                if (saless.CustomerName == customer.Name)
                {
                    sales.CustomerId = customer.Id;
                }
            }

            foreach (var store in stList)
            {
                if (saless.StoreName == store.Name)
                {
                    sales.StoreId = store.Id;
                }
            }

            foreach (var product in pList)
            {
                if (saless.ProductName == product.Name)
                {
                    sales.ProductId = product.Id;
                }
            }


            _context.Entry(sales).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SalesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }