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