Ejemplo n.º 1
0
        public ActionResult NewCargo(string orderingCustomer, string origin, string destination, DateTime?arrivalDeadline)
        {
            if (!arrivalDeadline.HasValue)
            {
                ViewData.ModelState.AddModelError("arrivalDeadline", "Arrival deadline is required and must be a valid date.");
            }
            if (origin == destination)
            {
                ViewData.ModelState.AddModelError("destination", "Destination of a cargo must be different from its origin.");
            }
            if (!ViewData.ModelState.IsValid)
            {
                AddShipingLocations();
                return(View());
            }
            string trackingId = _bookingFacade.BookNewCargo(orderingCustomer, origin, destination, arrivalDeadline.Value);

            return(RedirectToDetails(trackingId));
        }
        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(RedirectToAction("ListCargos"));
            //return RedirectToDetails(trackingId);
        }