コード例 #1
0
        public LogisticItemList UserLogisticItem(int UserId)
        {
            var item = (from ls in dbContext.LogisticServices
                        join cl in dbContext.CustomerLogistics on ls.LogisticServiceId equals cl.LogisticServiceId
                        join lsst in dbContext.LogisticServiceShipmentTypes on ls.LogisticServiceId equals lsst.LogisticServiceId
                        where cl.UserId == UserId
                        select new
            {
                ls.LogisticCompany,
                ls.LogisticCompanyDisplay,
                ls.LogisticType,
                ls.LogisticTypeDisplay,
                ls.RateType,
                ls.RateTypeDisplay,
                ls.ModuleType,
                lsst.LogisticDescription,
                lsst.LogisticDescriptionDisplayType
            }).ToList();

            if (item != null && item.Count > 0)
            {
                LogisticItemList ls = new LogisticItemList();
                var company         = item.Select(p => new { p.LogisticCompany, p.LogisticCompanyDisplay }).Distinct().OrderBy(p => p.LogisticCompany).ToList();
                var type            = item.Select(p => new { p.LogisticType, p.LogisticTypeDisplay }).Distinct().OrderBy(p => p.LogisticType).ToList();
                var rate            = item.Select(p => new { p.RateType, p.RateTypeDisplay }).Distinct().ToList();
                var shipment        = item.Select(p => new { p.LogisticDescription, p.LogisticDescriptionDisplayType }).Distinct().ToList();
                ls.ModuleType = item.Select(p => p.ModuleType).FirstOrDefault();

                ls.LogisticTypes = new List <LogisticServiceItem>();
                LogisticServiceItem lt;
                for (int i = 0; i < type.Count; i++)
                {
                    lt         = new LogisticServiceItem();
                    lt.Value   = type[i].LogisticType;
                    lt.Display = type[i].LogisticTypeDisplay;
                    ls.LogisticTypes.Add(lt);
                }

                ls.LogisticRateTypes = new List <LogisticServiceItem>();
                LogisticServiceItem lrt;
                for (int i = 0; i < rate.Count; i++)
                {
                    lrt = new LogisticServiceItem();
                    if (rate[i].RateType != null)
                    {
                        lrt.Value   = rate[i].RateType;
                        lrt.Display = rate[i].RateTypeDisplay;
                        ls.LogisticRateTypes.Add(lrt);
                    }
                }

                ls.LogisticCompanies = new List <LogisticServiceItem>();
                LogisticServiceItem lc;
                for (int i = 0; i < company.Count; i++)
                {
                    lc         = new LogisticServiceItem();
                    lc.Value   = company[i].LogisticCompany;
                    lc.Display = company[i].LogisticCompanyDisplay;
                    ls.LogisticCompanies.Add(lc);
                }

                ls.DocTypes = new List <LogisticServiceItem>();
                LogisticServiceItem lsst;
                for (int i = 0; i < shipment.Count; i++)
                {
                    lsst         = new LogisticServiceItem();
                    lsst.Value   = shipment[i].LogisticDescription;
                    lsst.Display = shipment[i].LogisticDescriptionDisplayType;
                    ls.DocTypes.Add(lsst);
                }

                return(ls);
            }
            return(null);
        }
コード例 #2
0
        public LogisticItemList GetLogisticItem(int OperationZoneId)
        {
            var item = dbContext.LogisticServices.Where(p => p.OperationZoneId == OperationZoneId && p.IsActive == true).ToList();

            if (item != null && item.Count > 0)
            {
                LogisticItemList ls = new LogisticItemList();
                var company         = item.Select(p => new { p.LogisticCompany, p.LogisticCompanyDisplay }).Distinct().OrderBy(p => p.LogisticCompany).ToList();
                var type            = item.Select(p => new { p.LogisticType, p.LogisticTypeDisplay }).Distinct().OrderBy(p => p.LogisticType).ToList();
                var rate            = item.Select(p => new { p.RateType, p.RateTypeDisplay }).Distinct().ToList();
                ls.ModuleType = item.Select(p => p.ModuleType).FirstOrDefault();

                ls.LogisticTypes = new List <LogisticServiceItem>();
                LogisticServiceItem lt;
                for (int i = 0; i < type.Count; i++)
                {
                    lt         = new LogisticServiceItem();
                    lt.Value   = type[i].LogisticType;
                    lt.Display = type[i].LogisticTypeDisplay;
                    ls.LogisticTypes.Add(lt);
                }

                ls.LogisticRateTypes = new List <LogisticServiceItem>();
                LogisticServiceItem lrt;
                for (int i = 0; i < rate.Count; i++)
                {
                    lrt = new LogisticServiceItem();
                    if (rate[i].RateType != null)
                    {
                        lrt.Value   = rate[i].RateType;
                        lrt.Display = rate[i].RateTypeDisplay;
                        ls.LogisticRateTypes.Add(lrt);
                    }
                }

                ls.LogisticCompanies = new List <LogisticServiceItem>();
                LogisticServiceItem lc;
                for (int i = 0; i < company.Count; i++)
                {
                    lc         = new LogisticServiceItem();
                    lc.Value   = company[i].LogisticCompany;
                    lc.Display = company[i].LogisticCompanyDisplay;
                    ls.LogisticCompanies.Add(lc);
                }

                //Will be done Anil
                ls.DocTypes = new List <LogisticServiceItem>();
                ls.DocTypes.Add(new LogisticServiceItem()
                {
                    Value = "Doc", Display = "Doc"
                });
                ls.DocTypes.Add(new LogisticServiceItem()
                {
                    Value = "Nondoc", Display = "Nondoc"
                });
                ls.DocTypes.Add(new LogisticServiceItem()
                {
                    Value = "Doc&Nondoc", Display = "Doc & Nondoc"
                });
                ls.DocTypes.Add(new LogisticServiceItem()
                {
                    Value = "HeavyWeight", Display = "Heavy Weight"
                });

                return(ls);
            }
            return(null);
        }