Beispiel #1
0
        //It will list out all the PostCodes assigned to the zones.
        public List <FrayteZonePostCode> GetZonePostCodeList(int OperationZoneId, string LogisticType, string CourierCompany, string RateType, string ModuleType)
        {
            List <FrayteZonePostCode> _postcode = new List <FrayteZonePostCode>();

            try
            {
                var zones = (from lsz in dbContext.LogisticServices
                             join lz in dbContext.LogisticServiceZones on lsz.LogisticServiceId equals lz.LogisticServiceId
                             where lsz.OperationZoneId == OperationZoneId &&
                             lsz.LogisticType == LogisticType &&
                             lsz.LogisticCompany == CourierCompany &&
                             lsz.RateType == RateType &&
                             lsz.ModuleType == ModuleType
                             select new
                {
                    lsz.LogisticServiceId,
                    lz.LogisticServiceZoneId
                }).ToList();

                if (zones != null && zones.Count > 0)
                {
                    int TotalRows = 0;
                    foreach (var zone in zones)
                    {
                        var result = dbContext.spGet_ZonePostcode(zone.LogisticServiceZoneId, zone.LogisticServiceId, CourierCompany, OperationZoneId, null, 0, 16).ToList();

                        if (result != null && result.Count > 0)
                        {
                            TotalRows = result[0].TotalRows.Value;
                        }
                        else
                        {
                            TotalRows = 0;
                        }

                        foreach (spGet_ZonePostcode_Result zonePostCode in result)
                        {
                            FrayteZonePostCode postCode = new FrayteZonePostCode();
                            postCode.ZonePostCodeId = zonePostCode.LogisticServiceZonePostCodeId;
                            postCode.PostCodeZone   = new FrayteZone()
                            {
                                ZoneId          = zonePostCode.LogisticServiceZoneId,
                                OperationZoneId = zonePostCode.OperationZoneId,
                                ZoneName        = zonePostCode.ZoneName,
                                ZoneDisplayName = zonePostCode.ZoneDisplayName
                            };
                            postCode.TransitTime = zonePostCode.transittime;
                            postCode.PostCode    = zonePostCode.PostCode;
                            postCode.IsActive    = true;

                            postCode.TotalRows = TotalRows;

                            _postcode.Add(postCode);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(_postcode);
        }