/// <summary> /// Crea un lote en la base de datos. /// </summary> /// <param name="VencimientoLote"></param> /// <param name="NumeroLote"></param> /// <param name="IdSuministro"></param> /// <returns>Retorna el id del lote creado. Retorna -1 si no se creo.</returns> public int CrearLote(DateTime VencimientoLote, string NumeroLote, int IdSuministro) { bool Perecedero = true; if (VencimientoLote == DateTime.MinValue) Perecedero = false; Lote lote = new Lote(VencimientoLote, NumeroLote, Perecedero); Suministro suministro = cSuministro.BuscarSuministro(IdSuministro); suministro.AddLote(lote); return mLote.CrearLote(lote); }
public int ActualizarLote(Lote lote) { try { db.Entry(lote).State = EntityState.Modified; db.SaveChanges(); return lote.LoteId; } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } return -1; }
public int CrearLote(Lote lote) { try { db.Lotes.Add(lote); db.SaveChanges(); return lote.LoteId; } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } return -1; }
// Lotes public void AddLote(Lote LoteSuministro) { this.LotesSuministros.Add(LoteSuministro); if (LoteSuministro.SuministroLote == null || !LoteSuministro.SuministroLote.Equals(this)) { LoteSuministro.SuministroLote = this; } }