public bool Save() { try { _context.SaveChanges(); } catch (DbEntityValidationException e) { HandleDbEntityValidationException(e); return(false); } catch (DbUpdateException e) { HandleDbUpdateException(e); return(false); } AcceptedChanges?.Invoke(this, EventArgs.Empty); return(true); }
public async Task <bool> SaveAsync(CancellationToken token) { using (await _monitor.LockAsync()) { try { await _context.SaveChangesAsync(token); } catch (DbEntityValidationException e) { HandleDbEntityValidationException(e); return(false); } catch (DbUpdateException e) { HandleDbUpdateException(e); return(false); } AcceptedChanges?.Invoke(this, EventArgs.Empty); return(true); } }