public override async Task <int> CreateAsync(IServiceInputModel servicesInputViewModel) { var parking = servicesInputViewModel.To <Parking>(); await this.parkingRepository.AddAsync(parking); var resultOne = await this.parkingRepository.SaveChangesAsync(); var lastParking = await this.parkingRepository.All().FirstOrDefaultAsync(p => p.Name == parking.Name); for (int i = 0; i < lastParking.Capacity; i++) { var parkingSlot = new ParkingSlot { Number = i, Status = Status.Free, ParkingId = lastParking.Id, }; await this.parkingSlotRepository.AddAsync(parkingSlot); } var resultTwo = await this.parkingSlotRepository.SaveChangesAsync(); return(resultOne + resultTwo); }
public virtual async Task <int> CreateAsync(IServiceInputModel servicesInputViewModel) { var entity = servicesInputViewModel.To <TEntity>(); await this.baseEntityRepository.AddAsync(entity); var result = await this.baseEntityRepository.SaveChangesAsync(); return(result); }
public virtual async Task <TKey> CreateAsync(IServiceInputModel servicesInputViewModel) { var entity = servicesInputViewModel.To <TEntity>(); await this.deletableEntityRepository.AddAsync(entity); await this.deletableEntityRepository.SaveChangesAsync(); return(entity.Id); }
public override async Task <int> CreateAsync(IServiceInputModel servicesInputViewModel) { var game = servicesInputViewModel.To <Game>(); await this.gamesRepository.AddAsync(game); await this.UpdateTeamsData(game); var result = await this.gamesRepository.SaveChangesAsync(); return(result); }
public override async Task <int> CreateAsync(IServiceInputModel servicesInputViewModel) { var trip = servicesInputViewModel.To <Trip>(); var car = await this.carsRepository.All() .Where(c => c.Id == trip.CarId) .FirstOrDefaultAsync(); car.HireStatus = SmartCarRentals.Data.Models.Enums.Car.HireStatus.Unavailable; this.carsRepository.Update(car); await this.tripsRepository.AddAsync(trip); var result = await this.tripsRepository.SaveChangesAsync(); return(result); }