public void AgregarRepuesto(Repuesto repuesto) { if (getCodigoExistente(repuesto.CodigoRepuesto)) { throw new CodigoExistenteException(); } else { _listaRepuestos.Add(repuesto); } }
public void ModificarRepuesto(Repuesto repuestoNuevo) { bool encuentra = false; for (int i = 0; i < _listaRepuestos.Count; i++) { if (_listaRepuestos[i].CodigoRepuesto == repuestoNuevo.CodigoRepuesto) { _listaRepuestos[i] = repuestoNuevo; encuentra = true; } } if (encuentra == false) { throw new Exception("No puedo modificar"); } }
public Repuesto TraerRepuestoByCodigo(int codigo) { Repuesto repuesto = null; foreach (Repuesto rep in _listaRepuestos) { if (codigo == rep.CodigoRepuesto) { repuesto = rep; } } if (repuesto == null) { throw new RepuestoExistenteException(); } return(repuesto); }
public void QuitarStock(int codigo, int stock) { Repuesto rep = TraerRepuestoByCodigo(codigo); if (rep.Stock > 0) { if (stock < rep.Stock) { rep.Stock = rep.Stock - stock; } else { throw new StockNegativoException(); } } else { throw new Exception("El repuesto cuenta con stock, no se puede eliminar"); } }
public void ModificarPrecio(int codigo, double precio) { Repuesto rep = TraerRepuestoByCodigo(codigo); rep.Precio = precio; }
public void AgregarStock(int codigo, int stock) { Repuesto rep = TraerRepuestoByCodigo(codigo); rep.Stock = rep.Stock + stock; }