title: ASP.NET Core Web API - The name 'jsonString' does not exist in the current context
body: <p>I am using ASP.NET Core Web API. I have this code:</p>
  <p>ViewModel (Dto):</p>
  <pre><code>public class MandateDto
  {
      public DateTime DueDate { get; set; }
      public DateTime StartDate { get; set; }
      public DateTime EndDate { get; set; }
      public int? MandateId { get; set; }
  }
  public class TransactionDto
  {
      public string? RawData { get; set; }
  }
  </code></pre>
  <p>EntityMapper:</p>
  <pre><code>public class EntityMapper
  {
      public Mandate FromMandateDtoToMandate(MandateDto mandate)
      {
          Mandate mandate = new Mandate()
          {
              DueDate = mandate.DueDate,
              StartDate = mandate.StartDate,
              EndDate = mandate.EndDate
          };
          string jsonString = JsonSerializer.Serialize(mandate);
          return mandate;
      }
  
      public TransactionLog FromMandateDtoToTransactionLog(TransactionDto mandate)
      {
          return new TransactionLog
          {
              RawData = jsonString,
          };
      }
  }
  </code></pre>
  <p>MandateService:</p>
  <pre><code>    public async Task&lt;Mandate&gt; Post(MandateDto mandate)
      {
          var mapper = new EntityMapper();
          var mandate = mapper.FromMandateDtoToMandate(mandate);
          var transaction = mapper.FromMandateDtoToTransactionLog(mandate);
  
          try
          {
              await _unitOfWork.MandateRepository.Insert(mandate);
              await _unitOfWork.TransactionRepository.Insert(transaction);
              await _unitOfWork.SaveChangesAsync();
          }
          catch (Exception e)
          {
              throw new Exception(e.Message);
          }
  
          return mandate;
          return transaction;
      }
  </code></pre>
  <p>As shown in <strong>EntityMapper</strong>, I want to transfer <strong>jsonString</strong> from <strong>FromMandateDtoToMandate</strong> into <strong>FromMandateDtoToTransactionLog</strong> as in:</p>
  <blockquote>
  <p>RawData = jsonString</p>
  </blockquote>
  <p>I got this error:</p>
  <blockquote>
  <p>Error CS0103  The name 'jsonString' does not exist in the current context</p>
  </blockquote>
  <p>How do I resolve this?</p>
  <p>Thanks.</p>