public async Task UpdateProgramWorkout(int id, CreateOrUpdateProgramWorkoutRequest request) { if (request.Period <= 0) { throw new ArgumentException(); } var pw = await context.ProgramWorkouts.FindAsync(id); pw.Name = request.Name; pw.AuthorId = request.AuthorId; pw.Period = request.Period; await context.SaveChangesAsync(); }
public async Task AddProgramWorkout(CreateOrUpdateProgramWorkoutRequest request) { if (request.Period <= 0) { throw new ArgumentException(); } var pw = new ProgramWorkout { Name = request.Name, AuthorId = request.AuthorId, Period = request.Period }; await context.ProgramWorkouts.AddAsync(pw); await context.SaveChangesAsync(); }