Exemplo n.º 1
0
        public ActionResult ListFreight(FreightModel FreightModel1, String FreightType)
        {
            ViewData["FreightType"] = FreightType;
            if (FreightType == null)
            {
                FreightType = FreightModel.FreightTypes.OceanFreight.ToString();
            }
            IEnumerable <Area> AreaListDep = _shipmentService.getAllAreaByCountry(FreightModel1.CountryNameDep == null ? 0 : FreightModel1.CountryNameDep);
            IEnumerable <Area> AreaListDes = _shipmentService.getAllAreaByCountry(FreightModel1.CountryNameDes == null ? 0 : FreightModel1.CountryNameDes);

            if (AreaListDep == null || AreaListDep.Count() < 0)
            {
                AreaListDep = new List <Area>();
            }
            if (AreaListDes == null || AreaListDes.Count() < 0)
            {
                AreaListDes = new List <Area>();
            }
            ViewData["AreaListDep"] = new SelectList(AreaListDep, "Id", "AreaAddress");
            ViewData["AreaListDes"] = new SelectList(AreaListDes, "Id", "AreaAddress");
            IEnumerable <Freight> FreightList1 = _freightService.getAllFreight(FreightModel1, FreightType);

            if ("Carrier".Equals(FreightModel1.SortType))
            {
                if ("asc".Equals(FreightModel1.SortOder))
                {
                    FreightList1 = FreightList1.OrderBy(m => m.CarrierAirLine.AbbName);
                }
                else
                {
                    FreightList1 = FreightList1.OrderByDescending(m => m.CarrierAirLine.AbbName);
                }
            }
            else if ("Agent".Equals(FreightModel1.SortType))
            {
                if ("asc".Equals(FreightModel1.SortOder))
                {
                    FreightList1 = FreightList1.OrderBy(m => m.Agent.AbbName);
                }
                else
                {
                    FreightList1 = FreightList1.OrderByDescending(m => m.Agent.AbbName);
                }
            }
            else if ("ValidDate".Equals(FreightModel1.SortType))
            {
                if ("asc".Equals(FreightModel1.SortOder))
                {
                    FreightList1 = FreightList1.OrderBy(m => m.ValidDate);
                }
                else
                {
                    FreightList1 = FreightList1.OrderByDescending(m => m.ValidDate);
                }
            }
            else
            {
                FreightList1 = FreightList1.OrderByDescending(m => m.UpdateDate);
            }
            ViewData["FreightList1"] = FreightList1;
            return(View(FreightModel1));
        }