public List <FrayteExchangeRateHistory> GetExchangeRateHistory(FrayteSearchExchangeHistory search) { try { List <FrayteExchangeRateHistory> _rate = new List <FrayteExchangeRateHistory>(); var detail = dbContext.OperationZoneExchangeRateHistories.Where(p => p.OperationZoneId == search.OperationZoneId && p.ExchangeType == search.ExchangeType && p.StartDate.Value.Year == search.Year && p.StartDate.Value.Month == search.MonthName.MonthId) .ToList(); if (detail != null && detail.Count > 0) { FrayteExchangeRateHistory frayte; foreach (var Obj in detail) { frayte = new FrayteExchangeRateHistory(); OperationZone oz = dbContext.OperationZones.Where(p => p.OperationZoneId == Obj.OperationZoneId.Value).FirstOrDefault(); if (oz != null) { frayte.OperationZone = new FrayteOperationZone(); { frayte.OperationZone.OperationZoneId = oz.OperationZoneId; frayte.OperationZone.OperationZoneName = oz.Name; } } CurrencyType ct = dbContext.CurrencyTypes.Where(x => x.CurrencyCode == Obj.CurrencyCode).FirstOrDefault(); if (ct != null) { frayte.CurrencyDetail = new FrayteCurrencyDetail(); { frayte.CurrencyDetail.CurrencyCode = ct.CurrencyCode; frayte.CurrencyDetail.Description = ct.CurrencyDescription; } } frayte.ExchangeType = Obj.ExchangeType; if (Obj.ExchangeRate.HasValue) { frayte.ExchangeRate = Obj.ExchangeRate.Value.ToString(); } if (Obj.StartDate.HasValue) { frayte.StartDate = Obj.StartDate.Value; } if (Obj.FinishDate.HasValue) { frayte.FinishDate = Obj.FinishDate.Value; } _rate.Add(frayte); } } return(_rate); } catch (Exception x) { return(null); } }
public List <FrayteThirdPartyMatrix> GetThirdPartyMatrixDetail(int OperationZoneId, string LogisticType, string CourierCompany, string RateType, string ModuleType) { List <FrayteThirdPartyMatrix> _thirdparty = new List <FrayteThirdPartyMatrix>(); try { OperationZone oz = dbContext.OperationZones.Where(x => x.OperationZoneId == OperationZoneId).FirstOrDefault(); _thirdparty = (from tpm in dbContext.LogisticServiceThirdPartyMatrices join fz in dbContext.LogisticServiceZones on tpm.FromLogisticServiceZoneId equals fz.LogisticServiceZoneId join tz in dbContext.LogisticServiceZones on tpm.ToLogisticServiceZoneId equals tz.LogisticServiceZoneId join az in dbContext.LogisticServiceZones on tpm.ApplyLogisticServiceZoneId equals az.LogisticServiceZoneId into tmpAZ from azT in tmpAZ.DefaultIfEmpty() join ls in dbContext.LogisticServices on tz.LogisticServiceId equals ls.LogisticServiceId where tpm.OperationZoneId == OperationZoneId && ls.OperationZoneId == OperationZoneId && ls.LogisticCompany == CourierCompany && ls.LogisticType == LogisticType && ls.RateType == RateType && ls.ModuleType == ModuleType select new FrayteThirdPartyMatrix { ApplyZone = new FrayteZone() { OperationZoneId = OperationZoneId, ZoneId = (azT.LogisticServiceId > 0 ? azT.LogisticServiceZoneId : 0), ZoneName = (azT.ZoneName == null ? "N/A" : azT.ZoneName), ZoneColor = (azT.ZoneColor == null ? "" : azT.ZoneColor), ZoneDisplayName = (azT.ZoneDisplayName == null ? "N/A" : azT.ZoneDisplayName), LogisticType = ls.LogisticType, CourierComapny = ls.LogisticCompany, RateType = ls.RateType, ModuleType = ls.ModuleType }, FromZone = new FrayteZone() { OperationZoneId = OperationZoneId, ZoneId = fz.LogisticServiceZoneId, ZoneName = fz.ZoneName, ZoneColor = fz.ZoneColor, ZoneDisplayName = fz.ZoneDisplayName, LogisticType = ls.LogisticType, CourierComapny = ls.LogisticCompany, RateType = ls.RateType, ModuleType = ls.ModuleType }, ToZone = new FrayteZone() { OperationZoneId = OperationZoneId, ZoneId = tz.LogisticServiceZoneId, ZoneName = tz.ZoneName, ZoneColor = tz.ZoneColor, ZoneDisplayName = tz.ZoneDisplayName, LogisticType = ls.LogisticType, CourierComapny = ls.LogisticCompany, RateType = ls.RateType, ModuleType = ls.ModuleType }, OperationZone = new FrayteOperationZone() { OperationZoneId = OperationZoneId, OperationZoneName = oz.Name }, ThirdPartyMatrixId = tpm.LogisticServiceThirdPartyMatrixId, }).ToList(); } catch (Exception ex) { return(null); } return(_thirdparty); }