public void NewOrUpdate(ChargingSession NewChargingSession,
                                Action <ChargingSession> UpdateFunc = null)
        {
            lock (InternalData)
            {
                if (!InternalData.ContainsKey(NewChargingSession.Id))
                {
                    InternalData.Add(NewChargingSession.Id, NewChargingSession);
                    UpdateFunc?.Invoke(NewChargingSession);

                    LogIt("new",
                          NewChargingSession.Id,
                          "chargingSession",
                          NewChargingSession.ToJSON());
                }
                else
                {
                    UpdateFunc?.Invoke(NewChargingSession);

                    LogIt("update",
                          NewChargingSession.Id,
                          "chargingSession",
                          NewChargingSession.ToJSON());
                }
            }
        }
Esempio n. 2
0
        public void New(ChargingReservation NewChargingReservation)
        {
            lock (InternalData)
            {
                if (!InternalData.ContainsKey(NewChargingReservation.Id))
                {
                    InternalData.Add(NewChargingReservation.Id, new ChargingReservationCollection(NewChargingReservation));

                    LogIt("new",
                          NewChargingReservation.Id,
                          "reservations",
                          new JArray(NewChargingReservation.ToJSON()));
                }

                else
                {
                    InternalData[NewChargingReservation.Id].Add(NewChargingReservation);

                    LogIt("update",
                          NewChargingReservation.Id,
                          "reservations",
                          new JArray(InternalData[NewChargingReservation.Id].Select(reservation => reservation.ToJSON())));
                }
            }
        }
        public void Remove(ChargingSession ChargingSession)
        {
            lock (InternalData)
            {
                if (ChargingSession != null &&
                    InternalData.ContainsKey(ChargingSession.Id))
                {
                    InternalData.Remove(ChargingSession.Id);

                    LogIt("remove",
                          ChargingSession.Id,
                          "chargingSession",
                          ChargingSession.ToJSON());
                }
            }
        }