Ejemplo n.º 1
0
 /// <summary>
 /// Loads DTO of cargo for cargo routing function.
 /// </summary>
 /// <param name="trackingId">Cargo tracking id.</param>
 /// <returns>DTO.</returns>
 public Reporting.Cargo LoadCargoForRouting(string trackingId)
 {
    ReportingDataContext context = new ReportingDataContext();
    Reporting.Cargo c = context.Cargos.FirstOrDefault(x => x.TrackingId == trackingId);
    if (c == null)
    {
       throw new ArgumentException("Cargo with specified tracking id not found.");
    }
    return c;
 }
Ejemplo n.º 2
0
 public ActionResult Track(string trackingId)
 {
    ReportingDataContext context = new ReportingDataContext();
    Reporting.Cargo cargo = context.Cargos.FirstOrDefault(x => x.TrackingId == trackingId);
    if (cargo == null)
    {
       ViewData.ModelState.AddModelError("trackingId", "Provided tracking id is invalid.");
       return View();
    }
    return View(new CargoTrackingViewAdapter(cargo));         
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns a complete list of cargos stored in the system.
 /// </summary>
 /// <returns>A collection of cargo DTOs.</returns>
 public IList<Reporting.Cargo> ListAllCargos()
 {
    ReportingDataContext context = new ReportingDataContext();
    return context.Cargos.ToList();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns a list of all defined shipping locations in format acceptable by MVC framework 
 /// drop down list.
 /// </summary>
 /// <returns>A list of shipping locations.</returns>
 public IList<SelectListItem> ListShippingLocations()
 {
    ReportingDataContext context = new ReportingDataContext();
    return context.Locations.Select(x => new SelectListItem { Text = x.Name, Value = x.UnLocode }).ToList();
 }