/// <summary>Updates the specified item.</summary> /// <param name="item">The item.</param> /// <returns>Task.</returns> public async Task Update(T item) { using (DistribuitorServiciiMobileContext context = new DistribuitorServiciiMobileContext()) { DbSet <T> dbSet = context.Set <T>(); dbSet.Attach(item); context.Entry(item).State = EntityState.Modified; await context.SaveChangesAsync(); } }
/// <summary>Deletes the specified entity.</summary> /// <param name="entity">The entity.</param> /// <returns>Task.</returns> public async Task Delete(T entity) { using (DistribuitorServiciiMobileContext context = new DistribuitorServiciiMobileContext()) { DbSet <T> dbSet = context.Set <T>(); if (context.Entry(entity).State == EntityState.Detached) { dbSet.Attach(entity); } dbSet.Remove(entity); await context.SaveChangesAsync(); } }