public static void Do <T>(this ITestTaskDbContext context, Action <DbSet <T> > act, Boolean shouldSave = false) where T : class { act(context.Set <T>()); if (!shouldSave) { return; } context.SaveChanges(); return; }
public static async Task Do <T>(this ITestTaskDbContext context, Func <DbSet <T>, Task> act, Boolean shouldSave = false) where T : class { await act(context.Set <T>()); if (!shouldSave) { return; } await context.SaveChangesAsync(); return; }
public static async Task <R> DoWithResult <T, R>(this ITestTaskDbContext context, Func <DbSet <T>, Task <R> > act, Boolean shouldSave = false) where T : class { var res = await act(context.Set <T>()); if (!shouldSave) { return(res); } await context.SaveChangesAsync(); return(res); }
public OrderDataService(ITestTaskDbContext dbContext, ILogger <IOrderDataService> logger) { context = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }