Ejemplo n.º 1
0
        public async Task <ActionResult> Put([FromBody] Product productUpdate)
        {
            var product = connection.Product.SingleOrDefault(a => a.id == productUpdate.id);

            if (product != null && ModelState.IsValid)
            {
                connection.Entry(product).CurrentValues.SetValues(productUpdate);
                await connection.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Put([FromBody] Category categoryUpdate)
        {
            var category = connection.Category.SingleOrDefault(a => a.id == categoryUpdate.id);

            if (category != null && ModelState.IsValid)
            {
                connection.Entry(category).CurrentValues.SetValues(categoryUpdate);
                await connection.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
        public async Task <ActionResult> Put([FromBody] Employee employeeUpdate)
        {
            var employee = connection.Employee.SingleOrDefault(a => a.id == employeeUpdate.id);

            if (employee != null && ModelState.IsValid)
            {
                connection.Entry(employee).CurrentValues.SetValues(employeeUpdate);
                await connection.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }