2017-03-05 89 views
1

我要儘量不要讓這個問題長。我正在爲一家旅館發送電子郵件確認信。int不是從變量打印

  • 如果出現了預約紅色和綠色的側邊欄顯示
  • 如果還沒有處於保留變化的變化,有一樣的背景。

問題是,它只是ArrivalDateTimeDepartureDateTime給我的電子郵件輸出。 orderRoomsorderTotalAmmount在電子郵件中沒有給我任何輸出。代碼編譯正常,但我沒有得到任何輸出結果在int

這怎麼可能?

ArrivalDateTime:印刷ArrivalDateTime

DepartureDateTime:印刷DepartureDateTime

總房數:不打印orderRooms

總價:不打印orderTotalAmmount

<!-- ArrivalDateTime --> 
@{ 
    var orderArrivalDateTime = Model.Order.ArrivalDateTime.ToString("dddd d. MMMM yyyy", new System.Globalization.CultureInfo("da-DK")); 
    var order2ArrivalDateTime = Model.Order2.ArrivalDateTime.ToString("dddd d. MMMM yyyy", new System.Globalization.CultureInfo("da-DK")); 
    bool hasChangedArrivalDateTime = orderArrivalDateTime != order2ArrivalDateTime; 
} 
<!-- DepartureDateTime --> 
@{ 
    var orderDepartureDateTime = Model.Order.DepartureDateTime.ToString("dddd d. MMMM yyyy", new System.Globalization.CultureInfo("da-DK")); 
    var order2DepartureDateTime = Model.Order2.DepartureDateTime.ToString("dddd d. MMMM yyyy", new System.Globalization.CultureInfo("da-DK")); 
    bool hasChangedDepartureDateTime = orderDepartureDateTime != order2DepartureDateTime; 
} 

<!-- Total number of rooms --> 
@{ 
    var orderRooms = Model.Order.OrderLines.Count; 
    var order2Rooms = Model.Order2.OrderLines.Count; 
    bool hasChangedorderRooms = orderRooms != order2Rooms; 
} 
<!-- Total price --> 
@{ 
    var orderTotalAmmount = Model.Order.TotalAmount; 
    var order2TotalAmmount = Model.Order2.TotalAmount; 
    bool hasChangedorderTotalAmmount = orderTotalAmmount != order2TotalAmmount; 
} 

HTML

<!-- ArrivalDateTime --> 
<table align="center" class="wrapper header float-center"> 
    <tr> 
     <td class="wrapper-inner"> 
      @renderOrderPropertyBlock(hasChangedArrivalDateTime, "Arrival", orderArrivalDateTime, order2ArrivalDateTime) 
     </td> 
    </tr> 
</table> 
<!-- DepartureDateTime --> 
<table align="center" class="wrapper header float-center"> 
    <tr> 
     <td class="wrapper-inner"> 
      @renderOrderPropertyBlock(hasChangedDepartureDateTime, "Departure", orderDepartureDateTime, order2DepartureDateTime) 
     </td> 
    </tr> 
</table> 

<!-- Total number of rooms --> 
<table align="center" class="wrapper header float-center"> 
    <tr> 
     <td class="wrapper-inner"> 
      @renderOrderPropertyBlock(hasChangedorderRooms, "Number of nights", orderRooms, order2Rooms) 
     </td> 
    </tr> 
</table> 

<!-- Total price --> 
<table align="center" class="wrapper header float-center"> 
    <tr> 
     <td class="wrapper-inner"> 
      @renderOrderPropertyBlock(hasChangedorderTotalAmmount, "Total price", orderTotalAmmount, order2TotalAmmount) 
     </td> 
    </tr> 
</table> 

還有很多更多的代碼,但是這應該是相關的代碼來顯示。

+1

嘗試從'@renderOrderPropertyBlock改變你的計數代碼(hasChangedorderRooms, 「停留天數」,orderRooms.ToString(),order2Rooms.ToString())' – Armin

+0

因爲我不知道什麼規則'wrapper header float-center'適用,它們可能在日期之後。嘗試刪除數據,如果你看到問題是CSS。 – Armin

+0

作品完美,非常感謝:-)請留下一個答案。 – Mimi

回答

2

您在整數的末尾缺少.ToString()。 更新您的代碼中使用

@renderOrderPropertyBlock(hasChangedorderRooms, "Number of nights", orderRooms.ToString(), order2Rooms.ToString()) 

@renderOrderPropertyBlock(hasChangedorderTotalAmmount, "Total price", orderTotalAmmount.ToString(), order2TotalAmmount.ToString())