public async Task <IActionResult> UpdateAsync(ContiBancariModel conto) { if (await InvService.UpdateAsync(conto).ConfigureAwait(false)) { return(Ok()); } else { return(BadRequest()); } }
public async Task <bool> UpdateAsync(ContiBancariModel conto) { try { DbContext.ContiBancari.Update(conto); await DbContext.SaveChangesAsync().ConfigureAwait(false); return(true); } catch (System.Exception) { return(false); } }
public async Task <bool> DeleteContoAsync(int id) { if (await DbContext.ContiBancari.AnyAsync(c => c.Id == id).ConfigureAwait(false)) { ContiBancariModel conto = await DbContext.ContiBancari .Where(c => c.Id == id) .FirstAsync() .ConfigureAwait(false); DbContext.ContiBancari.Remove(conto); await DbContext .SaveChangesAsync() .ConfigureAwait(false); return(true); } return(false); }
public async Task <bool> AddAsync(ContiBancariModel conto) { if (conto.CliforModelId > 0 && conto.IBAN != null) { try { DbContext.ContiBancari.Add(conto); await DbContext.SaveChangesAsync().ConfigureAwait(false); return(true); } catch (System.Exception) { return(false); } } return(false); }