示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }