Ejemplo n.º 1
0
        public void QuitarStock(int codigo, int stockRestado)
        {
            Repuesto repuesto = BuscarPorCodigo(codigo);

            if (repuesto != null)
            {
                repuesto.RestarStock(stockRestado);
            }
            else
            {
                throw new Excepciones.RepuestoInexistenteException(codigo);
            }
        }
Ejemplo n.º 2
0
        public void AgregarStock(int codigo, int stockAgregado)
        {
            Repuesto repuesto = BuscarPorCodigo(codigo);

            if (repuesto != null)
            {
                repuesto.Stock = repuesto.Stock + stockAgregado;
            }
            else
            {
                throw new Excepciones.RepuestoInexistenteException(codigo);
            }
        }
Ejemplo n.º 3
0
        public void EditarRepuesto(int codigo, string nombre, double precio, int stock, string categoria)
        {
            Repuesto repuesto = BuscarPorCodigo(codigo);

            if (repuesto != null)
            {
                this._listaProductos.Remove(repuesto);
                this._listaProductos.Add(new Repuesto(codigo, nombre, precio, stock, categoria));
            }
            else
            {
                throw new Excepciones.RepuestoInexistenteException(codigo);
            }
        }
Ejemplo n.º 4
0
        public void AgregarRepuesto(string nombre, double precio, int stock, string categoria)
        {
            Repuesto repuesto = new Repuesto(NuevoCodigo, nombre, precio, stock, categoria);

            foreach (Repuesto r in _listaProductos)
            {
                if (r.Equals(repuesto))
                {
                    throw new Excepciones.RepuestoExistenteException(r.Codigo);
                }
            }

            this._listaProductos.Add(repuesto);
        }
Ejemplo n.º 5
0
        public void QuitarRepuesto(int codigo)
        {
            Repuesto repuesto = this.BuscarPorCodigo(codigo);

            if (repuesto != null)
            {
                if (repuesto.Stock == 0)
                {
                    this._listaProductos.Remove(repuesto);
                }
                else
                {
                    throw new Exception("El repuesto aún tiene stock.");
                }
            }
            else
            {
                throw new Excepciones.RepuestoInexistenteException(codigo);
            }
        }
Ejemplo n.º 6
0
        public override bool Equals(object obj)
        {
            Repuesto repuestoExterno = (Repuesto)obj;

            return(this._nombre == repuestoExterno._nombre && this._categoria.Codigo == repuestoExterno._categoria.Codigo);
        }