public async Task <IActionResult> PutInterview(int id, Interview interview) { if (id != interview.Id) { return(BadRequest()); } _context.Entry(interview).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InterviewExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> GetAsync(int assetFieldId) { if (await _dbContext.AssetFields.AnyAsync(x => x.Id == assetFieldId)) { return(BadRequest()); } var valToRemove = await _dbContext.AssetFields.FirstOrDefaultAsync(x => x.Id == assetFieldId); _dbContext.AssetFields.Remove(valToRemove); await _dbContext.SaveChangesAsync(); return(Ok(valToRemove)); }
public async Task <IActionResult> DeleteAsync(int assetId) { if (!await _dbContext.Assets.AnyAsync(x => x.Id == assetId)) { return(BadRequest()); } var valToRemove = await _dbContext.Assets.FirstOrDefaultAsync(x => x.Id == assetId); valToRemove.IsDeleted = true; _dbContext.Assets.Update(valToRemove); await _dbContext.SaveChangesAsync(); return(Ok(valToRemove)); }
public async Task CommitAsync() { await _context.SaveChangesAsync(); }