public ActionResult GuardarEdicion(string nombre, int cantidad, string precioCompra, string precioVenta, string idpro) { productoBLL = new ProductoBLLImp(); Producto per = new Producto { nombre = nombre, cantidad = cantidad, precioCompra = precioCompra, precioVenta = precioVenta, idNombreEmpresa = (string)Session["empresa"], idProducto = idpro }; productoBLL.Modificar(per); return(Json(new { result = string.Empty }, JsonRequestBehavior.AllowGet)); }
public bool Crear(string idCompra, string[,] productos) { productoBLL = new ProductoBLLImp(); Producto pr; try { using (unitOfWork = new UnitOfWork(new GymContext())) { using (GymContext Context = new GymContext()) { for (int i = 0; i < productos.Length; i++) { if (productos[i, 0] == null) { return(true); } else { string id = ConsecutivoModifica("CRM"); CompraProducto cp = new CompraProducto() { idCompraProducto = id, idCompra = idCompra, idProducto = productos[i, 0], cantidad = int.Parse(productos[i, 1]), total = productos[i, 2] }; pr = productoBLL.BuscarPorId(productos[i, 0]); pr.cantidad = pr.cantidad - int.Parse(productos[i, 1]); unitOfWork.compraProductoDAL.Add(cp); productoBLL.Modificar(pr); unitOfWork.Complete(); } } } } return(true); } catch (Exception a) { string e = a.Message; return(false); } }