public virtual ActionResult IntransitShipmentListExcel(ShipmentListFilterModel filters) { string heading; switch (filters.Source) { case null: heading = "All Shipments"; break; case ShipmentSourceType.Vendor: heading = "Vendor Shipments"; break; case ShipmentSourceType.Transfer: heading = "Transfer Shipments"; break; default: throw new NotImplementedException(); } var list = GetShipmentModels(filters, Helpers.GlobalConstants.MAX_EXCEL_ROWS); var result = new ExcelResult("Inbound Shipment Summary"); //TODO: include filters in heading result.AddWorkSheet(list, "Shipments", heading); return(result); }
/// <summary> /// Copy constructor /// </summary> /// <param name="other"></param> public ShipmentListFilterModel(ShipmentListFilterModel other) { Source = other.Source; Status = other.Status; SewingPlantCode = other.SewingPlantCode; VariancesOnly = other.VariancesOnly; MinClosedDate = other.MinClosedDate; MaxClosedDate = other.MaxClosedDate; }
private IList <IntransitShipmentModel> GetShipmentModels(ShipmentListFilterModel filters, int maxRows) { ShipmentFilters statusFilter = ShipmentFilters.NoFilter; if (filters.Status == ShipmentStatusType.Open) { // Showing open shipments. statusFilter |= ShipmentFilters.OpenShipments; filters.MinClosedDate = null; filters.MaxClosedDate = null; } else { // Showing close shipments. statusFilter |= ShipmentFilters.ClosedShipments; } if (filters.VariancesOnly) { statusFilter |= ShipmentFilters.VarianceOnlyShipments; } switch (filters.Source) { case null: break; case ShipmentSourceType.Vendor: statusFilter |= ShipmentFilters.VendorShipments; break; case ShipmentSourceType.Transfer: statusFilter |= ShipmentFilters.BuildingTransferShipments; break; default: throw new NotImplementedException(); } // int nMaxRowsToShow = int.MaxValue; var shipmentList = _service.GetInboundShipmentSummary(filters.MinClosedDate, filters.MaxClosedDate, statusFilter, filters.SewingPlantCode, maxRows); var list = from row in shipmentList orderby(row.IsShipmentClosed?row.MaxUploadDate : row.ShipmentDate) descending select new IntransitShipmentModel(row); return(list.ToList()); }
public virtual ActionResult IntransitShipmentList(ShipmentListFilterModel filters) { //We want to show top 500 rows. int nMaxRowsToShow = 500; var shipmentLists = GetShipmentModels(filters, nMaxRowsToShow); var model = new IntransitShipmentListViewModel { Filters = filters }; //model.TotalShipmentRows = shipmentLists.Select(m => m.TotalShipmentCount).FirstOrDefault(); //model.MaxRowsToShow = nMaxRowsToShow; model.Shipments = shipmentLists; model.SewingPlantList = (from item in _service.GetSewingPlantList() select new SelectListItem { Text = string.Format("{0}:{1}", item.SewingPlantCode, item.PlantName), Value = item.SewingPlantCode }).ToList(); return(View(Views.IntransitShipmentList, model)); }