public async Task AddAuthor(CreateOrUpdateAuthorRequest request) { var auth = new Author { Name = request.Name }; await context.Authors.AddAsync(auth); await context.SaveChangesAsync(); }
public async Task AddPosition(CreateOrUpdatePositionRequest request) { var pos = new Position { Name = request.Name }; await context.Positions.AddAsync(pos); await context.SaveChangesAsync(); }
public async Task AddTrainer(CreateOrUpdateTrainerRequest request) { var tr = new Trainer { ProgramWorkoutId = request.ProgramWorkoutId, EmployeeId = request.EmployeeId }; await context.Trainers.AddAsync(tr); await context.SaveChangesAsync(); }
public async Task AddTrainingMachine(CreateOrUpdateTrainingMachineRequest request) { var gym = new TrainingMachine { Name = request.Name, IsForHand = request.IsForHand, IsForLeg = request.IsForLeg, IsForBack = request.IsForBack }; await context.TrainingMachines.AddAsync(gym); await context.SaveChangesAsync(); }
public async Task AddClient(CreateOrUpdateClientRequest request) { var client = new Client { Name = request.Name, LastName = request.LastName, TrainerId = request.TrainerId != 0 ? request.TrainerId : null, SubscriptionId = request.SubscriptionId != 0 ? request.SubscriptionId : null }; await context.Clients.AddAsync(client); 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(); }
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(); }
public async Task AddEmployee(CreateOrUpdateEmployeeRequest request) { if (request.Experience < 0 || request.Salary <= 0) { throw new ArgumentException(); } var emp = new Employee { Name = request.Name, PositionId = request.PositionId, Experience = request.Experience, Salary = request.Salary, GymId = request.GymId }; await context.Employees.AddAsync(emp); await context.SaveChangesAsync(); }