Esempio n. 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);
        }
Esempio n. 2
0
        public List <FrayteZonePostCode> GetZonePostCodeList(int OperationZoneId, string LogisticType, int ZoneId, string SearchPostcode, int CurrentPage, int TakeRows)
        {
            int TotalRows = 0;

            if (!string.IsNullOrEmpty(SearchPostcode))
            {
                SearchPostcode = "%" + SearchPostcode + "%";
            }

            int SkipRows = 0;

            SkipRows = (CurrentPage - 1) * TakeRows;

            List <FrayteZonePostCode> _postcode = new List <FrayteZonePostCode>();

            var service = (from lsz in dbContext.LogisticServiceZones
                           join ls in dbContext.LogisticServices on lsz.LogisticServiceId equals ls.LogisticServiceId
                           where lsz.LogisticServiceZoneId == ZoneId
                           select new
            {
                lsz.LogisticServiceId,
                ls.LogisticCompany
            }).FirstOrDefault();

            try
            {
                var result = dbContext.spGet_ZonePostcode(ZoneId, service.LogisticServiceId, service.LogisticCompany, OperationZoneId, SearchPostcode, SkipRows, TakeRows).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,
                        ZoneColor       = zonePostCode.ZoneColor,
                        ZoneDisplayName = zonePostCode.ZoneDisplayName
                    };
                    postCode.PostCode = zonePostCode.PostCode;
                    postCode.IsActive = true;

                    postCode.TotalRows = TotalRows;

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