public KeysDto Update(KeysDto keysDto) { var meterKeys = GetExistingMeterKey(keysDto.Serial); meterKeys.UpdateFields(keysDto); var meter = _meterRepository.GetBySerial(keysDto.Serial); if (meter == null) { return(_mapper.Map <MeterKeys, KeysDto>(_meterKeyRepository.Update(meterKeys))); } HttpResponseMessage status; meter.MeterKeys = meterKeys; if (meter.Smc == null) { status = _meterForwarderService.ForwardEdition(_mapper.Map <Meter, MeterDto>(meter)); } else { var smc = _mapper.Map <SmcDto>(meter.Smc); smc.KeysDto = keysDto; status = _smcForwarderService.ForwardEdition(smc); } if (!status.IsSuccessStatusCode) { throw new BadRequestException(JsonConvert .DeserializeObject <ErrorMessageDto>(status.Content.ReadAsStringAsync().Result).ErrorMessage); } return(_mapper.Map <MeterKeys, KeysDto>(_meterKeyRepository.Update(meterKeys))); }
public static void CreateRSAKey(string privateKeyPath, string publicKeyPath) { KeysDto keys = GetRSAKey(); FileHelper.CreateFile(privateKeyPath, keys.PrivateKey); FileHelper.CreateFile(publicKeyPath, keys.PublichKey); }
public KeysDto Create(KeysDto keysDto) { var meterKeys = _meterKeyRepository.GetBySerial(keysDto.Serial); if (meterKeys != null) { throw new ExistentEntityException("As chaves do medidor de serial " + keysDto.Serial + " já existem na base de dados"); } return(_mapper.Map <MeterKeys, KeysDto>(_meterKeyRepository.Create(_mapper.Map <KeysDto, MeterKeys>(keysDto)))); }
public IActionResult Save(KeysDto keysDto) { var keys = _meterKeyService.Create(keysDto); return(new CreatedResult( _servicesUtils .CreateUri( Request, Url.RouteUrl( "GetBySerialRoute", new { serial = keys.Serial })), keysDto)); }
private Smc CreateSmc(SmcDto smc, KeysDto keysDto) { smc.KeysDto = keysDto; smc.SmcModel = _smcModelService.GetByName(smc.SmcModel.Name); var status = _smcForwarderService.ForwardCreation(smc); if (!status.IsSuccessStatusCode) { throw new BadRequestException(JsonConvert .DeserializeObject <ErrorMessageDto>(status.Content.ReadAsStringAsync().Result).ErrorMessage); } _smcService.Save(smc); return(_smcService.GetExistingSmc(smc.Serial)); }
public void UpdateFields(KeysDto keysDto) { Ak = keysDto.Ak; Ek = keysDto.Ek; Mk = keysDto.Mk; }
public IActionResult Update(KeysDto keysDto) { return(new OkObjectResult(_meterKeyService.Update(keysDto))); }