public async Task <bool> DeleteAmentity(int id) { Amentity amentity = await GetAmentity(id); if (amentity == null) { return(false); } _context.Entry(amentity).State = EntityState.Deleted; await _context.SaveChangesAsync(); return(true); }
public async Task <IActionResult> PutAmentity(int id, Amentity amentity) { if (id != amentity.Id) { return(BadRequest()); } if (!await _amentityRepo.PutAmentity(amentity)) { return(NotFound()); } return(NoContent()); }
public async Task <bool> PutAmentity(Amentity amentity) { _context.Entry(amentity).State = EntityState.Modified; try { await _context.SaveChangesAsync(); // Save worked return(true); } catch (DbUpdateConcurrencyException) { if (!AmentityExists(amentity.Id)) { return(false); } else { throw; } } }
public async Task <ActionResult <Amentity> > PostAmentity(Amentity amentity) { await _amentityRepo.CreateAmentity(amentity); return(CreatedAtAction("GetAmentity", new { id = amentity.Id }, amentity)); }
public async Task CreateAmentity(Amentity amentity) { _context.Amenities.Add(amentity); await _context.SaveChangesAsync(); }