Ejemplo n.º 1
0
        public async Task <IActionResult> PutLot(int id, Lot lot)
        {
            if (id != lot.Id)
            {
                return(BadRequest());
            }

            _context.Entry(lot).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LotExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutCalibrator(int id, Calibrator calibrator)
        {
            if (id != calibrator.Id)
            {
                return(BadRequest());
            }

            _context.Entry(calibrator).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CalibratorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 3
0
        public async Task <bool> AddVenta(bool created, Venta venta)
        {
            Venta lastOne = await LastReceived();

            // find venta
            var existingVenta = _context.Ventas.Find(venta.IdentificadorVenta, venta.IdLinea);

            if (null == existingVenta)
            {
                if (null != lastOne && lastOne.EsUltimoRecibido)
                {
                    lastOne.EsUltimoRecibido = false;
                }

                _context.Ventas.Add(venta);
                created = true;
            }
            else
            {
                // update existing with incoming
                existingVenta.CantidadVendida   = venta.CantidadVendida;
                existingVenta.CodLaboratorio    = venta.CodLaboratorio;
                existingVenta.CodProducto       = venta.CodProducto;
                existingVenta.DescProducto      = venta.DescProducto;
                existingVenta.EsGenerico        = venta.EsGenerico;
                existingVenta.FechaVenta        = venta.FechaVenta;
                existingVenta.LoteOptimo        = venta.LoteOptimo;
                existingVenta.NombreLaboratorio = venta.NombreLaboratorio;
                existingVenta.PVP           = venta.PVP;
                existingVenta.StockActual   = venta.StockActual;
                existingVenta.StockMaximo   = venta.StockMaximo;
                existingVenta.StockMinimo   = venta.StockMinimo;
                existingVenta.TipoVenta     = venta.TipoVenta;
                existingVenta.FechaRecibido = DateTime.Now;
            }


            await _context.SaveChangesAsync();

            return(created);
        }