public ActionResult Create(QuotedPriceViewModel vm)
        {
            vm.QuotedPriceDetails  = vm.SettedConfigs.FromJsonStringTo <IEnumerable <QuotedPriceDetail> >();
            vm.RelatedCustomerID   = vm.Target == 0 ? vm.TargetID : vm.RelatedCustomerID;
            vm.RelatedCustomerName = vm.TargetID == 0 ? vm.TargetName : vm.RelatedCustomerName;

            AddQuotedPriceRequest request = new AddQuotedPriceRequest()
            {
                QuotedPrices = vm.QuotedPriceDetails.Select(q => new QuotedPrice()
                {
                    ProjectID            = base.UserInfo.ProjectID,
                    ProjectName          = base.UserInfo.ProjectName,
                    Target               = vm.Target,
                    TargetID             = vm.TargetID,
                    TargetName           = vm.TargetName,
                    ShipperTypeID        = vm.ShipperTypeID,
                    ShipperTypeName      = vm.ShipperTypeName,
                    PodTypeID            = vm.PodTypeID,
                    PodTypeName          = vm.PodTypeName,
                    TplOrTtlID           = vm.TplOrTtlID,
                    TplOrTtlName         = vm.TplOrTtlName,
                    TransportationLineID = vm.TransportationLineID,
                    StartCityID          = vm.StartCityID,
                    StartCityName        = vm.StartCityName,
                    EndCityID            = vm.EndCityID,
                    EndCityName          = vm.EndCityName,
                    SegmentDetailID      = q.SegmentDetailID,
                    StartVal             = q.StartVal,
                    EndVal               = q.EndVal,
                    MinPrice             = vm.MinPrice ?? 0,
                    Point = vm.Point ?? 0,
                    Price = q.Price,
                    EffectiveStartTime = vm.EffectiveStartTime,
                    EffectiveEndTime   = vm.EffectiveEndTime,
                    Creator            = base.UserInfo.Name,
                    CreateTime         = DateTime.Now,
                    Remark             = vm.Remark,
                    State               = true,
                    RelatedCustomerID   = vm.RelatedCustomerID,
                    RelatedCustomerName = vm.RelatedCustomerName,
                    EmptyCarryPrice     = vm.EmptyCarryPrice ?? 0,
                    Decimal1            = vm.Decimal1 ?? 0,
                    Decimal2            = vm.Decimal2 ?? 0
                })
            };

            var response = new QuotedPriceService().AddQuotedPrice(request);

            if (response.IsSuccess)
            {
                ApplicationConfigHelper.RefreshProjectQuotedPrice(base.UserInfo.ProjectID, vm.Target, vm.TargetID, vm.RelatedCustomerID);
                return(RedirectToAction("Create", new { id = vm.Target, message = "新增报价成功,继续增加" }));
            }

            return(Error("新增" + (vm.Target == 0 ? "客户" : "承运商") + "报价失败!"));
        }
        public ActionResult List(int id)
        {
            QuotedPriceViewModel vm = new QuotedPriceViewModel();

            vm.Target = id;
            if (vm.Target == 0)
            {
                //vm.CustomerOrShippers = ApplicationConfigHelper.GetProjectCustomers(base.UserInfo.ProjectID).Select(c => new SelectListItem() { Value = c.CustomerID.ToString(), Text = c.Name });
                vm.CustomerOrShippers = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Select(c => new SelectListItem()
                {
                    Value = c.CustomerID.ToString(), Text = c.CustomerName
                });
            }
            else
            {
                vm.CustomerOrShippers = ApplicationConfigHelper.GetProjectShippers(base.UserInfo.ProjectID).Select(c => new SelectListItem()
                {
                    Value = c.ShipperID.ToString(), Text = c.Name
                });
            }

            if (vm.CustomerOrShippers == null || !vm.CustomerOrShippers.Any())
            {
                return(Error("请先关联项目" + (id == 0 ? "客户" : "承运商")));
            }

            var transportationLines = ApplicationConfigHelper.GetTransportationLine();

            if (!transportationLines.Any())
            {
                return(Error("请先设置系统运输线路"));
            }
            else
            {
                vm.TransportationLines = transportationLines.Select(t => new SelectListItem()
                {
                    Value = t.ID.ToString() + "|" + t.StartCityID.ToString() + "|" + t.StartCityName + "|" + t.EndCityID.ToString() + "|" + t.EndCityName, Text = t.StartCityName + "-" + t.EndCityName
                });
            }


            vm.ShipperTypes = ApplicationConfigHelper.GetSystemConfigs(base.UserInfo.ProjectID, WebConstants.SHIPPERTYPE)
                              .Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(), Text = c.Name
            });
            vm.PodTypes = ApplicationConfigHelper.GetSystemConfigs(base.UserInfo.ProjectID, WebConstants.PODTYPE)
                          .Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(), Text = c.Name
            });
            vm.TplOrTtl = ApplicationConfigHelper.GetSystemConfigs(base.UserInfo.ProjectID, WebConstants.TTLORTPL)
                          .Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(), Text = c.Name
            });
            vm.RelatedCustomers = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID)
                                  .Select(c => new SelectListItem()
            {
                Value = c.CustomerID.ToString(), Text = c.CustomerName
            });

            return(View(vm));
        }