예제 #1
0
 public ActionResult Edit([Bind(Include = "ID,ID_PRODUTO,ID_USUARIO")] CARRINHO cARRINHO)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cARRINHO).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cARRINHO));
 }
예제 #2
0
 public ActionResult Edit([Bind(Include = "ID,NOME,DESCRICAO,PRECO")] PRODUTO pRODUTO)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pRODUTO).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pRODUTO));
 }
예제 #3
0
 public ActionResult Edit([Bind(Include = "ID,E_MAIL,SENHA")] USUARIO uSUARIO)
 {
     if (ModelState.IsValid)
     {
         db.Entry(uSUARIO).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(uSUARIO));
 }
예제 #4
0
        public async Task <EntityResponse <TEntity> > Edit(TEntity entity)
        {
            var result = await context.Set <TEntity>().ContainsAsync(entity);

            if (!result)
            {
                return(new EntityResponse <TEntity>("The element not found"));
            }

            try
            {
                context.Entry(entity).State = EntityState.Modified;
                await context.SaveChangesAsync();

                return(new EntityResponse <TEntity>(entity));
            }
            catch (Exception ex)
            {
                // Do some logging stuff
                return(new EntityResponse <TEntity>($"An error occurred when updating the element: {ex.Message}"));
            }
        }