private void InsertReservations(IEnumerable<Reservation> reservations)
 {
     var resovationRepo = new ReservationRepository();
     foreach (var reservation in reservations)
     {
         resovationRepo.Insert(reservation);
     }
 }
        public bool ReserveBattery(string stationValue, string userValue)
        {
            var userRepo = new UserRepository();
            var reservationRepo = new ReservationRepository();
            var batteryRepo = new BatteryRepository();
            var station = _stationRepository.GetStationById(Convert.ToInt32(stationValue), true);
            var user = userRepo.GetUserById(Convert.ToInt32(userValue));

            if (user == null || station == null)
                return false;

            var isBatteryAvailable = station.BatteryStorages.Available > 0;
            if (isBatteryAvailable)
            {
                var batteryCollection =
                    station.BatteryStorages.BatteryCollections.FirstOrDefault(x => x.Battery.Status == 1);
                if (batteryCollection != null)
                {
                    var battery = batteryCollection.Battery;
                    battery.Status = 3;

                    var reservation = new Reservation
                    {
                        UserId = user.ID,
                        StationId = station.ID,
                        CreatedDate = DateTime.Now,
                        ExpiredDate = DateTime.Now.AddDays(1),
                        IsActive = true
                    };

                    reservationRepo.Insert(reservation);
                    batteryRepo.Update(battery);

                    return true;
                }
            }

            return false;
        }