public async Task UpdateSubscription(int id, CreateOrUpdateSubscriptionRequest request) { if (request.Price <= 0 || request.Time <= 0) { throw new ArgumentException(); } var sub = await context.Subscriptions.FindAsync(id); sub.Name = request.Name; sub.Price = request.Price; sub.Time = request.Time; await context.SaveChangesAsync(); }
public async Task AddSubscription(CreateOrUpdateSubscriptionRequest request) { if (request.Price <= 0 || request.Time <= 0) { throw new ArgumentException(); } var sub = new Subscription { Name = request.Name, Price = request.Price, Time = request.Time }; await context.Subscriptions.AddAsync(sub); await context.SaveChangesAsync(); }