Permalink
Browse files

Added Knockout, initial demo done

  • Loading branch information...
1 parent af655c5 commit 22ec29a0340cee40bf156a8ee2a7e81f5e868aa0 @subsonic subsonic committed Jun 22, 2012
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -26,7 +26,7 @@ public ViewResult Index()
var order = db.Orders.Find(id);
order.Status = "refunded";
order.Notes = new List<OrderNote>();
- order.Notes.Add(new OrderNote { Note = "Order Refunded: Authorization XYZ", CreatedOn = DateTime.Now });
+ order.Notes.Add(new OrderNote { Note = "Order Refunded: Authorization XYZ by " + User.Identity.Name, CreatedOn = DateTime.Now });
TempData["message"] = "Order Refunded";
return RedirectToAction("edit", new {id = id});
}
@@ -35,10 +35,19 @@ public ActionResult Void(int id)
var order = db.Orders.Find(id);
order.Status = "voided";
order.Notes = new List<OrderNote>();
- order.Notes.Add(new OrderNote { Note = "Order Voided", CreatedOn = DateTime.Now });
+ order.Notes.Add(new OrderNote { Note = "Order Voidedby " + User.Identity.Name, CreatedOn = DateTime.Now });
TempData["message"] = "Order Voided by " + User.Identity.Name;
return RedirectToAction("edit", new { id = id });
}
+ public ActionResult Ship(int id)
+ {
+ var order = db.Orders.Find(id);
+ order.Status = "shipped";
+ order.Notes = new List<OrderNote>();
+ order.Notes.Add(new OrderNote { Note = "Order Shipped by " + User.Identity.Name, CreatedOn = DateTime.Now });
+ TempData["message"] = "Order Shipped by " + User.Identity.Name;
+ return RedirectToAction("edit", new { id = id });
+ }
//
// GET: /Default1/Details/5
Binary file not shown.
Binary file not shown.
@@ -5,6 +5,7 @@
<package id="jQuery.UI.Combined" version="1.8.11" />
<package id="jQuery.Validation" version="1.8.0" />
<package id="jQuery.vsdoc" version="1.5.1" />
+ <package id="knockoutjs" version="2.1.0" targetFramework="net40" />
<package id="Modernizr" version="1.7" />
<package id="Mvc3CodeTemplatesCSharp" version="3.0.11214.0" targetFramework="net40" />
</packages>
@@ -33,15 +33,16 @@
<div class='row nudge-top'>
<div class='span4'>
<div class='well'>
- <h4>Customer</h4>
+
+ <h4 data-bind="text:FullName"></h4>
+
<table class='left-right'>
<tr>
<td class='attribute'>
@Html.Raw(Html.Gravatar(Model.Email,50))
</td>
<td class='value'>
- <h5>
- @Model.Email</h5>
+ <h5 data-bind="text:Email"></h5>
</td>
</tr>
</table>
@@ -74,17 +75,24 @@
<div class='row span7'>
<div class='well'>
<form accept-charset="UTF-8" action="/orders/13487" method="post" novalidate="novalidate">
- @Forms.TextBoxRequired("FirstName",@Model.FirstName)
- @Forms.TextBoxRequired("LastName", @Model.LastName)
- @Forms.TextBox("Email",@Model.Email)
- @Forms.TextBoxRequired("Address",@Model.Address)
- @Forms.TextBoxRequired("City",@Model.City)
- @Forms.TextBoxRequired("State",@Model.State)
- @Forms.TextBox("PostalCode",@Model.PostalCode)
- @Forms.TextBox("Country",@Model.Country)
+
+ <label for="FirstName">Email</label>
+ <input name="FirstName" data-bind="value : FirstName" />
+
+ <label for="LastName">Email</label>
+ <input name="LastName" data-bind="value : LastName" />
+
+ <label for="Email">Email</label>
+ <input name="Email" data-bind="value : Email" />
+
+ @Forms.TextBoxRequired("Address",Model.Address)
+ @Forms.TextBoxRequired("City",Model.City)
+ @Forms.TextBoxRequired("State",Model.State)
+ @Forms.TextBox("PostalCode",Model.PostalCode)
+ @Forms.TextBox("Country",Model.Country)
- @Forms.TextBoxNumber("Total", @Model.Total)
- @Forms.TextBoxDate("OrderDate", @Model.OrderDate)
+ @Forms.TextBoxNumber("Total", Model.Total)
+ @Forms.TextBoxDate("OrderDate",Model.OrderDate)
<hr />
<input type="submit" class="btn btn-primary btn-ok" value = "save"/>
</form>
@@ -206,4 +214,18 @@
</div>
</div>
</div>
-@Forms.DeleteConfirmScript()
+@Forms.DeleteConfirmScript()
+<script type="text/javascript">
+
+ var orderViewModel = function () {
+
+ this.Email = ko.observable("@Model.Email");
+ this.FirstName = ko.observable("@Model.FirstName");
+ this.LastName = ko.observable("@Model.LastName");
+ this.FullName = ko.computed(function () {
+ return this.FirstName() + " " + this.LastName();
+ }, this);
+ }
+ ko.applyBindings(new orderViewModel());
+
+</script>
@@ -8,6 +8,7 @@
<meta name="author" content="Microsoft with the help of Tekpub">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
+ <script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.1.0.js"></script>
<script src="/assets/js/bootstrap.min.js"></script>
<script src="/assets/js/bootstrap-collapse.js"></script>
<script src="/assets/js/notifier.js"></script>
Oops, something went wrong.

0 comments on commit 22ec29a

Please sign in to comment.