我有主计长和观点,使用户能够检查购物车的内容。
当我的主计长将命令模式退回到检查结果时,所有人员都做了罚款。 然而,我现在要把购物单的内容显示在检查前,因此修改了主计长和观点,以使用含有订单和智能系统的观点。
我建立了“Model”号报,并修改了“GET:and POST: ActionResults to use this viewmodel”。
问题是,在《刑法》期间,《婚姻法》中没有适当的人种:
我正在拿不反对的字句,不要在此行文中打字。 Order.Username =user.Identity. 姓名;在《行动计划》中:行动结果,但我肯定不是确切的,什么是没有被遗忘的。
如果需要的话,我可以张贴使用Oreder模式的原工作编码,而不是“ReoutViewModel”。
我确信,我有一些简单的动乱或yn子问题,我可以告诉我们,因为我仍然试图以最佳方式在多国师委员会做事。
GET: ActionResult
//GET: /Checkout/AddressAndPayment
public ActionResult AddressAndPayment()
{
//To pre-populate the form, create a new Order object and get the ShoppingCart, populate the ViewModel and pass it to the view
var order = new Order();
order.Username = User.Identity.Name;
MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
storeDB.SaveChanges();
var cart = ShoppingCart.GetCart(this.HttpContext);
// Set up our ViewModel
var viewModel = new CheckoutViewModel
{
CartItems = cart.GetCartItems(),
CartTotal = cart.GetTotal(),
Order = order
};
// Return the view
return View(viewModel);
}
www.un.org/spanish/ecosoc POST: ActionResult
//POST: /Checkout/AddressAndPayment
[HttpPost]
public ActionResult AddressAndPayment(FormCollection values)
{
var checkoutViewModel = new CheckoutViewModel();
TryValidateModel(checkoutViewModel);
try
{
checkoutViewModel.Order.Username = User.Identity.Name;
checkoutViewModel.Order.OrderDate = DateTime.Now;
//Save Order
storeDB.Orders.Add(checkoutViewModel.Order);
storeDB.SaveChanges();
//Process the order
var cart = ShoppingCart.GetCart(this.HttpContext);
cart.CreateOrder(checkoutViewModel.Order);
storeDB.SaveChanges();
//Send Order Confirmation email
ViewData["order"] = checkoutViewModel.Order;
UserMailer.OrderConfirmation(checkoutViewModel.Order).SendAsync();
return RedirectToAction("Complete", new { id = checkoutViewModel.Order.OrderID });
}
catch
{
//Invalid - redisplay with errors
return View(checkoutViewModel);
}
}
@model OrderUp.ViewModels.CheckoutViewModel
@{
ViewBag.Title = "AddressAndPayment";
}
<script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<h2>Pick Up Details</h2>
<fieldset>
<legend>When are you gonna be hungry?</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Order.Phone)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Order.Phone)
@Html.ValidationMessageFor(model => model.Order.Phone)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Order.PickUpDateTime)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Order.PickUpDateTime)
@Html.ValidationMessageFor(model => model.Order.PickUpDateTime)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Order.Notes)
</div>
<div class="editor-multiline-field">
@Html.EditorFor(model => model.Order.Notes)
@Html.ValidationMessageFor(model => model.Order.Notes)
</div>
</fieldset>
<input type="submit" value="Submit Order" />
}
<div style="height:30px;"></div>
<h3>
<em>Review</em> your cart:
</h3>
<table>
<tr>
<th>
Menu Item
</th>
<th>
Price (each)
</th>
<th>
Notes
</th>
<th>
Quantity
</th>
<th></th>
</tr>
@foreach (var item in Model.CartItems)
{
<tr id="[email protected]">
<td>
@Html.ActionLink(item.MenuItem.Name, "Details", "Store", new { id = item.MenuItemID }, null)
</td>
<td>
@Html.DisplayFor(modelItem => item.MenuItem.Price)
</td>
<td>
@Html.DisplayFor(modelItem => item.Notes )
</td>
<td id="[email protected]">
@item.Count
</td>
<td>
</td>
</tr>
}
<tr>
<td >
Total
</td>
<td id="cart-total">
@String.Format("${0:F2}", Model.CartTotal)
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>