Esempio n. 1
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));
        }
Esempio n. 2
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));
        }