Exemple #1
0
        public Endpoint Execute(string identifier)
        {
            var endpoint = dao.FindOne(identifier);

            if (endpoint == null)
            {
                throw new AppException(I18nService.GetTranslate("DONT_HAVE_SERIAL_NUMBER"));
            }
            return(endpoint);
        }
Exemple #2
0
        public Endpoint Execute(EndpointVO endpointVo)
        {
            var matchedEndpoint = dao.FindOne(endpointVo.serialNumber);

            if (matchedEndpoint == null)
            {
                throw new AppException(I18nService.GetTranslate("DONT_HAVE_SERIAL_NUMBER"));
            }
            var endpoint = new Endpoint()
            {
                serialNumber = endpointVo.serialNumber,
            };

            EndpointValidator.ValidateSwitchState(endpointVo.switchState, endpoint);
            return(dao.Edit(endpoint));
        }
Exemple #3
0
        public Endpoint Execute(EndpointVO endpointVo)
        {
            if (dao.FindOne(endpointVo.serialNumber) != null)
            {
                throw new AppException(I18nService.GetTranslate("SERIAL_NUMBER_DUPLICATED"));
            }

            var endpoint = new Endpoint()
            {
                serialNumber         = endpointVo.serialNumber,
                meterFirmwareVersion = endpointVo.meterFirmwareVersion,
                meterNumber          = int.Parse(endpointVo.meterNumber),
            };

            EndpointValidator.ValidateModelId(endpointVo.meterModelId, endpoint);
            EndpointValidator.ValidateSwitchState(endpointVo.switchState, endpoint);

            return(dao.Create(endpoint));
        }