Exemplo n.º 1
0
        public IHttpActionResult PutWebPayTransaction(long id, Transaction webPayTransaction)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != webPayTransaction.Id)
            {
                return(BadRequest());
            }

            db.Entry(webPayTransaction).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WebPayTransactionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutCargo(int id, Cargo cargo)
        {
            if (id != cargo.ID_cargo)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 3
0
        public IHttpActionResult PutMarca(int id, Marca marca)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != marca.Id)
            {
                return(BadRequest());
            }

            db.Entry(marca).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MarcaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutTiendaItem(int id, TiendaItem tiendaItem)
        {
            if (id != tiendaItem.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "CustomerId,CompanyName,ContactName")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "ProductId,ProductName,UnitPrice")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,City,Country,Phone")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
Exemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "productoID,nombreProducto,unidadesDisponibles")] Producto producto)
 {
     if (ModelState.IsValid)
     {
         db.Entry(producto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(producto));
 }
 public ActionResult Edit([Bind(Include = "ClienteID,Nombre,Apellidos,Edad,Email")] Cliente cliente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cliente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cliente));
 }
 public ActionResult Edit([Bind(Include = "CategoriaID,Nombre,Descripcion")] Categoria categoria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categoria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categoria));
 }
Exemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "compraID,valorProductos,fechadecompra")] Compra compra)
 {
     if (ModelState.IsValid)
     {
         db.Entry(compra).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(compra));
 }
Exemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "clienteID,nombre,numeroTelefono,numeroCompras")] Cliente cliente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cliente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cliente));
 }
Exemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "Id,Nombre")] Marca marca)
 {
     if (ModelState.IsValid)
     {
         db.Entry(marca).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(marca));
 }
Exemplo n.º 14
0
 public ActionResult Edit([Bind(Include = "OrderId,OrderDate,CustomerId")] Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerId = new SelectList(db.Customers, "CustomerId", "CompanyName", order.CustomerId);
     return(View(order));
 }
Exemplo n.º 15
0
 public ActionResult Edit([Bind(Include = "Id,Nombre,Costo,Precio,categoriaid, marcaid")] Producto producto)
 {
     if (ModelState.IsValid)
     {
         db.Entry(producto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewData["Categorias"] = db.Categorias.ToList();
     ViewBag.Marcas         = new SelectList(db.Marcas.ToList(), "Id", "Nombre");
     return(View(producto));
 }
Exemplo n.º 16
0
 public ActionResult Edit([Bind(Include = "OrderDetailId,OrderId,ProductId,Quantity,UnitPrice")] OrderDetail orderDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrderId   = new SelectList(db.Orders, "OrderId", "OrderId", orderDetail.OrderId);
     ViewBag.ProductId = new SelectList(db.Products, "ProductId", "ProductName", orderDetail.ProductId);
     return(View(orderDetail));
 }
Exemplo n.º 17
0
 public ActionResult Edit([Bind(Include = "CompraID,ProductoID,ClienteID,SubTotal,FechaCompra")] Compra compra)
 {
     if (ModelState.IsValid)
     {
         db.Entry(compra).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClienteID  = new SelectList(db.Clientes, "ClienteID", "Nombre", compra.ClienteID);
     ViewBag.ProductoID = new SelectList(db.Productos, "ProductoID", "Nombre", compra.ProductoID);
     return(View(compra));
 }
 public ActionResult Edit([Bind(Include = "ProductoID,Nombre,Precio,Descripcion,RutaImagen,CategoriaID")] Producto producto)
 {
     if (ModelState.IsValid)
     {
         if (producto.RutaImagen == null | producto.RutaImagen == "")
         {
             producto.RutaImagen = "https://previews.123rf.com/images/pavelstasevich/pavelstasevich1811/pavelstasevich181101027/112815900-no-image-available-icon-flat-vector.jpg";
         }
         db.Entry(producto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoriaID = new SelectList(db.Categorias, "CategoriaID", "Nombre", producto.CategoriaID);
     return(View(producto));
 }
Exemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "Id,Nombre,Costo,Precio,categoriaid, marcaid")] Producto producto)
 {
     if (ModelState.IsValid)
     {
         HttpPostedFileBase file = Request.Files["ImageData"];
         if (file != null)
         {
             Utilidades.UploadImageProductoToDataBase(file, producto);
         }
         db.Entry(producto).State = EntityState.Modified;
         db.SaveChanges();
         string url = Url.Action("Lista", "Producto", new { id = producto.Id });
         return(Json(new { url = url, success = true, mensaje = "Producto registrado exitosamente" }));
     }
     ViewData["Categorias"] = db.Categorias.ToList();
     ViewBag.Marcas         = new SelectList(db.Marcas.ToList(), "Id", "Nombre");
     return(View("_Edit", producto));
 }
Exemplo n.º 20
0
 public ActionResult Delete(int id)
 {
     try
     {
         Cliente clienteABorrar = new Cliente()
         {
             ID = id
         };
         db.Entry(clienteABorrar).State = EntityState.Deleted;
         db.SaveChanges();
     }
     catch (DataException /* dex */)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.
         return(RedirectToAction("Delete", new { id = id, saveChangesError = true }));
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 21
0
        public ActionResult Edit(Producto producto)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    db.Entry(producto).State = EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                return(View(producto));
            }
            catch
            {
                return(View(producto));
            }
        }