Esempio n. 1
0
        public async Task <IActionResult> PutValue(int id, Value value)
        {
            if (id != value.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
 //Método de Exclusão
 public virtual void Delete(TEntity obj)
 {
     using (DataContex d = new DataContex())
     {
         d.Entry(obj).State = EntityState.Deleted;
         d.SaveChanges();
     }
 }
Esempio n. 3
0
 //Método de inserção
 public virtual void Insert(TEntity obj)
 {
     using (DataContex d = new DataContex())
     {
         d.Entry(obj).State = EntityState.Added;
         d.SaveChanges();
     }
 }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "Id,Name,Price,CategoryId")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
Esempio n. 5
0
 public ActionResult Edit(Manga manga)
 {
     if (ModelState.IsValid)
     {
         db.Entry(manga).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(manga));
 }
 public ActionResult Edit(Product product)
 {
     if (ModelState.IsValid)
     {
         contex.Entry(product).State = EntityState.Modified;
         contex.SaveChanges();
         return(RedirectToAction("Index", "Home"));
     }
     return(View(product));
 }