Exemplo n.º 1
0
        public async Task <T> Get(int id)
        {
            var category = await _context.Set <T>().FindAsync(id);

            _context.Entry(category).State = EntityState.Detached;
            return(category);
        }
Exemplo n.º 2
0
        public async Task <bool> SetFound(int id)
        {
            var pet = await _context.Pets.FindAsync(id);

            if (await CurrUserCanEdit(pet))
            {
                pet.Found = 1;
                _context.Entry(pet).State = EntityState.Modified;
            }
            return(await _context.SaveChangesAsync() > 0);
        }
Exemplo n.º 3
0
 public async Task <bool> Update(AnimalType animalType)
 {
     //Le decimos a la DB que el animalType fue modificado
     _context.Entry(animalType).State = EntityState.Modified;
     _logger.Information("AnimalType {name} updated, Id: {id}", animalType.Name, animalType.Id);
     return(await _context.SaveChangesAsync() > 0);
 }
Exemplo n.º 4
0
 public async Task <bool> Update(Gender gender)
 {
     _context.Entry(gender).State = EntityState.Modified;
     return(await _context.SaveChangesAsync() > 0);
 }
Exemplo n.º 5
0
 public async Task <bool> Update(City city)
 {
     _context.Entry(city).State = EntityState.Modified;
     _logger.Information("City {name} updated, Id: {id}", city.Name, city.Id);
     return(await _context.SaveChangesAsync() > 0);
 }