ddd_sample_app_ruby
ddd_sample_app_ruby copied to clipboard
New Cargo
From the .NET implementation:
NewCargo.aspx
<%@ Page Title="Book new cargo" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="DDDSample.UI.BookingAndTracking.Models" %>
<asp:Content ID="bookNewCargoTitle" ContentPlaceHolderID="TitleContent" runat="server">
Book new cargo
</asp:Content>
<asp:Content ID="bookNewCargoContent" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
$(document).ready(function() {
$("#arrivalDeadlineDatepicker").datepicker({ altField: '#arrivalDeadline' });
});
</script>
<h2>
Book new cargo</h2>
<p>
Use the form below to book a new cargo.
</p>
<%= Html.ValidationSummary() %>
<% using (Html.BeginForm())
{ %>
<div>
<fieldset>
<legend>Cargo information</legend>
<p>
<label for="origin">
Origin:</label>
<%= Html.DropDownList("origin")%>
</p>
<p>
<label for="destination">
Destination:</label>
<%= Html.DropDownList("destination")%>
</p>
<p>
<label for="arrivalDeadline">
Arrival deadline:</label>
<%= Html.TextBox("arrivalDeadline") %>
<%= Html.ValidationMessage("arrivalDeadline", "*")%>
<div type="text" id="arrivalDeadlineDatepicker">
</div>
</p>
<p>
<input type="submit" value="Book" />
</p>
</fieldset>
</div>
<% } %>
</asp:Content>
BookingController.cs
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult NewCargo(string origin, string destination, DateTime? arrivalDeadline)
{
bool validationError = false;
if (!arrivalDeadline.HasValue)
{
ViewData.ModelState.AddModelError("arrivalDeadline", @"Arrival deadline is required and must be a valid date.");
validationError = true;
}
if (origin == destination)
{
ViewData.ModelState.AddModelError("destination", @"Destination of a cargo must be different from its origin.");
validationError = true;
}
if (validationError)
{
AddShipingLocations();
return View();
}
string trackingId = _bookingFacade.BookNewCargo(origin, destination, arrivalDeadline.Value);
return RedirectToDetails(trackingId);
}
How do you associate a pull request with an issue?
See https://github.com/blog/1506-closing-issues-via-pull-requests. Good reminder for me to do this too.
Thanks! I'll remember that for next time. :)
•• Sent from my iPhone ••
On Sep 17, 2014, at 8:34 PM, Paul Rayner [email protected] wrote:
See https://github.com/blog/1506-closing-issues-via-pull-requests. Good reminder for me to do this too.
— Reply to this email directly or view it on GitHub.