Example #1
0
 public static void Afectar(Ordenes orden)
 {
     try
     {
         List <OrdenesDetalle> detalle = orden.Detalle;
         foreach (OrdenesDetalle det in detalle)
         {
             Productos producto = ProductosBLL.Buscar(det.ProductoId);
             if (producto != null)
             {
                 producto.Iventario += det.Cantidad;
                 ProductosBLL.Guardar(producto);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
        private static bool Modificar(Ordenes orden)
        {
            bool     paso     = false;
            Contexto contexto = new Contexto();

            try
            {
                contexto.Database.ExecuteSqlRaw($"Delete FROM MorasDetalle Where MoraId={orden.OrdenId}");

                foreach (var item in orden.Detalle)
                {
                    contexto.Entry(item).State = EntityState.Added;
                }

                List <OrdenesDetalle> detalle = orden.Detalle;
                foreach (OrdenesDetalle det in detalle)
                {
                    Productos producto = ProductosBLL.Buscar(det.ProductoId);
                    if (producto != null)
                    {
                        producto.Iventario -= det.Cantidad;
                        ProductosBLL.Guardar(producto);
                    }
                }
                Afectar(orden);



                contexto.Entry(orden).State = EntityState.Modified;
                paso = contexto.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }
            return(paso);
        }