int不是从变量打印

时间:2017-03-05 15:36:56

标签: c# razor

我会尽量不长时间地提出这个问题。我正在为酒店发送电子邮件确认函。

  • 如果预订发生变化,则会显示红色和绿色侧边栏
  • 如果预订没有变化,则背景相同。

问题是,只有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 个答案:

答案 0 :(得分:2)

您在整数末尾缺少.ToString()。 更新您的代码以使用

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

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