public async ValueTask Delete(long id) { await using var ctxt = new OrdersDbContext(optionsBuilder.Options); var res = await ctxt.Products.FirstOrDefaultAsync(x => x.Id == id); ctxt.Remove(res); await ctxt.SaveChangesAsync(); }
public async ValueTask <long> Create(ProductDbo productDbo) { await using var ctxt = new OrdersDbContext(optionsBuilder.Options); await ctxt.Products.AddAsync(productDbo); await ctxt.SaveChangesAsync(); return(productDbo.Id); }
public async ValueTask Update(long id, ProductDbo productDbo) { await using var ctxt = new OrdersDbContext(optionsBuilder.Options); var res = await ctxt.Products.FirstOrDefaultAsync(x => x.Id == id); res.Name = productDbo.Name; res.Description = productDbo.Description; res.Price = productDbo.Price; await ctxt.SaveChangesAsync(); }