ddd_sample_app_ruby icon indicating copy to clipboard operation
ddd_sample_app_ruby copied to clipboard

New Cargo

Open paulrayner opened this issue 9 years ago • 3 comments

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);
      }

paulrayner avatar Sep 13 '14 00:09 paulrayner

How do you associate a pull request with an issue?

drsharp avatar Sep 18 '14 00:09 drsharp

See https://github.com/blog/1506-closing-issues-via-pull-requests. Good reminder for me to do this too.

paulrayner avatar Sep 18 '14 02:09 paulrayner

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.

drsharp avatar Sep 18 '14 02:09 drsharp