public async Task <bool> RemoveAsync(T entity) { try { using (dbContext = dbContext.GetContext()) { dbContext.Entry(entity).State = EntityState.Deleted; await dbContext.SaveChangesAsync(); } } catch (Exception ex) { return(false); } return(true); }
public async Task <bool> UpdateAsync(T entity) { try { using (dbContext = dbContext.GetContext()) { dbContext.Set <T>().AddOrUpdate(entity); //dbContext.Entry<T>(entity).State = EntityState.Modified; await dbContext.SaveChangesAsync(); } } catch (Exception ex) { return(false); } return(true); }
public async Task <bool> AddAsync(T entity) { try { using (dbContext = dbContext.GetContext()) { dbContext.Set <T>().Attach(entity); dbContext.Set <T>().Add(entity); await dbContext.SaveChangesAsync(); } } catch (Exception ex) { return(false); } return(true); }