public async Task <IActionResult> PutProduto(long id, Produto produto)
        {
            if (id != produto.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> PutCategory(int id, Category category)
        {
            if (id != category.CategoryID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "ProductID,Name,UnitsInStock,CategoryId,UnitPrice")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
예제 #4
0
 public ActionResult Edit([Bind(Include = "CategoryID,Name,Description")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
예제 #5
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            category.Name            = txtName.Text.Trim();
            category.Description     = txtDescription.Text.Trim();
            db.Entry(category).State = EntityState.Modified;
            db.SaveChanges();

            MessageBox.Show("Category successfully modified");
            this.categoryDataGridView.Refresh();
            Clear();
        }