Exemplo n.º 1
0
        public List <TradelaneGetShipmentModel> GetTradelaneShipments(TradelaneTrackDirectBooking track)
        {
            List <TradelaneGetShipmentModel> ShipmentList = new List <TradelaneGetShipmentModel>();

            if (track != null)
            {
                FrayteOperationZone OperationZone = UtilityRepository.GetOperationZone();
                int RoleId    = dbContext.UserRoles.Where(p => p.UserId == (track.UserId > 0 ? track.UserId : track.CustomerId)).FirstOrDefault().RoleId;
                int TotalRows = 0;
                int SkipRows  = 0;
                SkipRows = (track.CurrentPage - 1) * track.TakeRows;
                DateTime?fromdate;
                DateTime?todate;
                var      Airline = "";

                if (track.FromDate.HasValue)
                {
                    fromdate = track.FromDate.Value;
                }
                else
                {
                    fromdate = track.FromDate;
                }

                if (track.ToDate.HasValue)
                {
                    todate = track.ToDate.Value;
                }
                else
                {
                    todate = track.ToDate;
                }

                if (track.MAWB != null && track.MAWB != "")
                {
                    var Result1 = GetMawbStr(track.MAWB);
                    track.MAWB = Result1.Item1;
                    Airline    = Result1.Item2;
                }

                var Result = dbContext.spGet_TradelaneTrackAndTraceDetail(track.MAWB, fromdate, todate, track.ShipmentStatusId, track.FrayteNumber, SkipRows, track.TakeRows, track.CustomerId, track.UserId, OperationZone.OperationZoneId, RoleId, track.SpecialSearchId, Airline).ToList();
                foreach (var res in Result)
                {
                    var STCode = "";
                    TradelaneGetShipmentModel Shipment = new TradelaneGetShipmentModel();
                    Shipment.DepartureAirport     = res.DepartureAirport;
                    Shipment.DestinationAirport   = res.DestinationAirport;
                    Shipment.CustomerId           = res.CustomerId;
                    Shipment.CreatedOn            = res.CreatedOnUtc.Date;
                    Shipment.Customer             = res.ContactName;
                    Shipment.IsAgentMAWBAllocated = res.IsAgentMAWBAllocated != null ? res.IsAgentMAWBAllocated.Value : false;
                    Shipment.MAWBAgentId          = res.MAWBAgentId != null ? res.MAWBAgentId.Value : 0;
                    Shipment.TradelaneShipmentId  = res.TradelaneShipmentId;
                    STCode                 = !string.IsNullOrEmpty(res.ShipmentHandlerMethodCode) ? " (" + res.ShipmentHandlerMethodCode + ')' : "";
                    Shipment.Status        = res.StatusName;
                    Shipment.StatusDisplay = res.DisplayStatusName + STCode;
                    Shipment.MAWB          = res.MAWB;
                    Shipment.TotalWeight   = res.TotalWeight != null ? res.TotalWeight.Value : 0;
                    Shipment.TotalCarton   = res.TotalCartons != null ? res.TotalCartons.Value : 0;
                    Shipment.TotalRows     = res.TotalRows.Value;
                    ShipmentList.Add(Shipment);
                }
                return(ShipmentList.OrderBy(a => a.Status).ToList());
            }
            return(ShipmentList);
        }