private void SumaLotes() { foreach (var p in partidas) { if (p.LoteId != null) { var prod = productoController.SelectOne(p.ProductoId); if (prod != null) { var l = loteController.SelectOneByNoLote(p.NoLote); if (l == null) { l = new Lote(); l.NoLote = p.NoLote; l.StockInicial = p.Cantidad; l.StockRestante = p.Cantidad; l.ProductoId = p.ProductoId; loteController.InsertOne(l); } else { l.StockRestante += p.Cantidad; loteController.Update(l); } } } } }