示例#1
0
        public Connector CreateConnector(Connector connector)
        {
            ThrowIf.Argument.IsNull(connector, nameof(connector));

            _ConnectorValidator.ValidateCreate(connector);

            connector.CK_Id = _ConnectorKeyGenerator.GenerateKey(GetConnectorsByChargeStation(connector.ChargeStationId));

            _UnitOfWork.ConnectorRepository.Add(connector);
            _UnitOfWork.SaveChanges();

            return(connector);
        }
        public ChargeStation CreateChargeStation(ChargeStation chargeStation, List <Connector> connectors)
        {
            ThrowIf.Argument.IsNull(chargeStation, nameof(chargeStation));
            ThrowIf.Argument.IsNull(connectors, nameof(connectors));

            _ChargeStationValidator.ValidateCreate(chargeStation, connectors);

            _UnitOfWork.ChargeStationRepository.Add(chargeStation);

            //Load connectors from given collection
            chargeStation.Connectors = connectors;

            //Generate keys
            foreach (var item in chargeStation.Connectors)
            {
                item.CK_Id = _ConnectorKeyGenerator.GenerateKey(chargeStation.Connectors);
            }

            //Save
            _UnitOfWork.SaveChanges();

            return(chargeStation);
        }