@Override
  public CommandProcessingResult updateMediaDetailsCrashStatus(Long clientId, JsonCommand command) {
    try {
      String message = null;
      this.context.authenticatedUser();
      String crashReportString = command.stringValueOfParameterNamed("crashReportString");
      SelfCare selfCare = SelfCareRetrieveByClientId(clientId);
      selfCare.setStatus("INACTIVE");

      Configuration configurationData =
          this.configurationRepository.findOneByName(
              ConfigurationConstants.CONFIG_PROPERTY_MEDIA_CRASH_EMAIL);

      if (configurationData != null
          && configurationData.isEnabled()
          && configurationData.getValue() != null) {
        message =
            this.messagePlatformEmailService.sendGeneralMessage(
                configurationData.getValue(), crashReportString, "Crash Api Report");
        if (message.equalsIgnoreCase("Success")) {
          message = clientId.toString();
        }
      }

      if (message == null) {
        message = "Please Enable the configuration Property";
      }

      return new CommandProcessingResult(message);

    } catch (DataIntegrityViolationException dve) {
      handleCodeDataIntegrityIssues(command, dve);
      return CommandProcessingResult.empty();
    }
  }
  @Transactional
  @Override
  public CommandProcessingResult createLinkupAccount(JsonCommand command) {

    try {

      this.context.authenticatedUser();
      this.apiJsonDeserializer.validateForCreate(command);

      final String uniqueReference = command.stringValueOfParameterNamed("userName");
      final String deviceId = command.stringValueOfParameterNamed("deviceId");

      SelfCare repository = selfCareRepository.findOneByEmail(uniqueReference);

      if (repository != null) {

        String dateFormat = "dd MMMM yyyy";
        String activationDate =
            new SimpleDateFormat(dateFormat).format(DateUtils.getDateOfTenant());

        JSONObject bookDevice = new JSONObject();
        List<ItemMaster> itemMaster = this.itemRepository.findAll();
        bookDevice.put("locale", "en");
        bookDevice.put("dateFormat", dateFormat);
        bookDevice.put("allocationDate", activationDate);
        bookDevice.put("provisioningSerialNumber", deviceId);
        try {
          bookDevice.put("itemType", itemMaster.get(0).getId());
        } catch (JSONException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        bookDevice.put("serialNumber", deviceId);
        bookDevice.put("status", "ACTIVE");
        CommandWrapper commandWrapper =
            new CommandWrapperBuilder()
                .createOwnedHardware(repository.getClientId())
                .withJson(bookDevice.toString())
                .build();
        final CommandProcessingResult result =
            portfolioCommandSourceWritePlatformService.logCommandSource(commandWrapper);

        if (result == null) {

          throw new PlatformDataIntegrityException(
              "error.msg.client.device.assign.failed",
              "Device Assign Failed for ClientId :" + repository.getClientId(),
              "Device Assign Failed");
        }

        String emailId = repository.getUserName();
        String password = repository.getPassword();
        String body =
            "Your Linkup Account activated successfully."
                + "<br/>"
                + "The following are credentils"
                + "<br/>"
                + "Username:"******" "
                + emailId
                + "&nbsp;"
                + "and "
                + "Password:"******" "
                + password;
        String subject = "Linkup Account";
        String header = "Hai,<br/>";
        String footer = "<br/><br/>Thanks";
        BillingMessageTemplate messageDetails =
            this.billingMessageTemplateRepository.findByTemplateDescription("NONE");

        if (messageDetails != null) {
          BillingMessage billingMessage =
              new BillingMessage(
                  header,
                  body,
                  footer,
                  BillingMessageTemplateConstants.MESSAGE_TEMPLATE_EMAIL_FROM,
                  emailId,
                  subject,
                  BillingMessageTemplateConstants.MESSAGE_TEMPLATE_STATUS,
                  messageDetails,
                  BillingMessageTemplateConstants.MESSAGE_TEMPLATE_MESSAGE_TYPE,
                  null);

          this.messageDataRepository.save(billingMessage);
        }
      } else {
        throw new ClientNotFoundException(uniqueReference);
      }

      return new CommandProcessingResultBuilder()
          .withEntityId(repository.getId())
          .withClientId(repository.getClientId())
          .build();

    } catch (DataIntegrityViolationException dve) {
      handleDataIntegrityIssues(command, dve);
      return new CommandProcessingResult(Long.valueOf(-1));
    } catch (JSONException e) {
      e.printStackTrace();
      return new CommandProcessingResult(Long.valueOf(-1));
    }
  }