示例#1
0
        public bool UpdateAlquiler(RequestAlquilerUpdate alquilerUpdate)
        {
            var entity = _dbContext.Alquileres.FirstOrDefault(a => a.ClienteId == alquilerUpdate.cliente && a.ISBN == alquilerUpdate.ISBN && a.EstadoId == 1);

            if (entity == null)
            {
                throw new Exception("Alquiler no encontrado");
            }
            // update to Alquiler
            entity.EstadoId        = 2;
            entity.FechaAlquiler   = DateTime.Now;
            entity.FechaDevolucion = DateTime.Now.AddDays(7);
            _dbContext.SaveChanges();
            return(true);
        }
示例#2
0
        public bool LibroDiscountStock(string ISBN)
        {
            var entity = _dbContext.Libros.FirstOrDefault(l => l.ISBN == ISBN);

            // Validate entity is not null
            if (entity != null)
            {
                if (entity.Stock != 0)
                {
                    entity.Stock = entity.Stock - 1;
                    _dbContext.SaveChanges();
                    return(true);
                }
            }
            return(false);
        }
示例#3
0
 public void Add <T>(T entity) where T : class
 {
     _context.Add(entity);
     _context.SaveChanges();
 }