Beispiel #1
0
        public ActionResult Create(CRMShipperOperationViewModel vm)
        {
            if (vm.PostedDeliveryOfVehicleTypes != null && vm.PostedDeliveryOfVehicleTypes.Any())
            {
                StringBuilder deliveryOfVehicleSB = new StringBuilder();
                vm.PostedDeliveryOfVehicleTypes.Each((i, s) => {
                    deliveryOfVehicleSB.Append(s).Append("|");
                });
                deliveryOfVehicleSB.Remove(deliveryOfVehicleSB.Length - 1, 1);
                vm.CRMShipper.DeliveryOfVehicleType = deliveryOfVehicleSB.ToString();
            }

            if (vm.PostedSixCards != null && vm.PostedSixCards.Any())
            {
                StringBuilder sixCardsSB = new StringBuilder();
                vm.PostedSixCards.Each((i, s) =>
                {
                    sixCardsSB.Append(s).Append("|");
                });
                sixCardsSB.Remove(sixCardsSB.Length - 1, 1);
                vm.CRMShipper.SixCard = sixCardsSB.ToString();
            }

            if (vm.PostedTermialOfVehicleTypes != null && vm.PostedTermialOfVehicleTypes.Any())
            {
                StringBuilder termialOfVehicleTypeSB = new StringBuilder();
                vm.PostedTermialOfVehicleTypes.Each((i, s) =>
                {
                    termialOfVehicleTypeSB.Append(s).Append("|");
                });
                termialOfVehicleTypeSB.Remove(termialOfVehicleTypeSB.Length - 1, 1);
                vm.CRMShipper.TermialOfVehicleType = termialOfVehicleTypeSB.ToString();
            }

            if (vm.PostedTransportModes != null && vm.PostedTransportModes.Any())
            {
                StringBuilder transportModesSB = new StringBuilder();
                vm.PostedTransportModes.Each((i, s) =>
                {
                    transportModesSB.Append(s).Append("|");
                });
                transportModesSB.Remove(transportModesSB.Length - 1, 1);
                vm.CRMShipper.TransportMode = transportModesSB.ToString();
            }


            if (vm.PostedTrunkOfVehicleTypes != null && vm.PostedTrunkOfVehicleTypes.Any())
            {
                StringBuilder trunkOfVehicleTypesSB = new StringBuilder();
                vm.PostedTrunkOfVehicleTypes.Each((i, s) =>
                {
                    trunkOfVehicleTypesSB.Append(s).Append("|");
                });
                trunkOfVehicleTypesSB.Remove(trunkOfVehicleTypesSB.Length - 1, 1);
                vm.CRMShipper.TrunkOfVehicleType = trunkOfVehicleTypesSB.ToString();
            }
            //创建时间,创建人,更新时间,更新人
            if (vm.ViewType == 1)
            {
                vm.CRMShipper.Creator    = base.UserInfo.Name;
                vm.CRMShipper.CreateTime = DateTime.Now;
            }

            vm.CRMShipper.UpdateTime = DateTime.Now;
            vm.CRMShipper.Updator    = base.UserInfo.Name;
            //
            var insertOrUpdateCRMShipperResponse = new ShipperManagementService().AddOrUpdateCRMShippers(new AddOrUpdateCRMShippersRequest()
            {
                CRMShipperCollection = new List <CRMShipper> {
                    vm.CRMShipper
                }
            });


            // 插入更新结果如果成功
            if (insertOrUpdateCRMShipperResponse.IsSuccess)
            {
                if (insertOrUpdateCRMShipperResponse.Result != null && insertOrUpdateCRMShipperResponse.Result.Any())
                {
                    long id = insertOrUpdateCRMShipperResponse.Result.First();
                    var  getCRMShipperResponse = new ShipperManagementService().GetCRMShipperInfo(new CRMShipperOperationRequest()
                    {
                        CRMShipperID = id
                    });
                    if (getCRMShipperResponse.IsSuccess)
                    {
                        vm.ViewType   = 0;
                        vm.CRMShipper = getCRMShipperResponse.Result.CRMShipper;
                        vm.CRMShipperCooperationCollection        = getCRMShipperResponse.Result.CRMShipperCooperationCollection;
                        vm.CRMShipperTransportationLineCollection = getCRMShipperResponse.Result.CRMShipperTransportationLineCollection;
                        return(View(vm));
                    }
                }
            }
            return(View(vm));
        }
Beispiel #2
0
        public ActionResult Create(long?id, int?ViewType)
        {
            CRMShipperOperationViewModel vm = new CRMShipperOperationViewModel();

            if (!id.HasValue)
            {
                vm.ViewType   = 1;
                vm.CRMShipper = new CRMShipper();
                vm.CRMShipper.AttachmentGroupID = Guid.NewGuid().ToString();
                vm.CRMShipper.Str3 = Guid.NewGuid().ToString();
            }
            else
            {
                var getCRMShipperResponse = new ShipperManagementService().GetCRMShipperInfo(new CRMShipperOperationRequest()
                {
                    CRMShipperID = id
                });
                if (getCRMShipperResponse.IsSuccess)
                {
                    vm.CRMShipper = getCRMShipperResponse.Result.CRMShipper;
                    if (vm.CRMShipper == null)
                    {
                        vm.CRMShipper = new CRMShipper();
                    }

                    if (!string.IsNullOrEmpty(vm.CRMShipper.DeliveryOfVehicleType))
                    {
                        IList <SelectListItem> selectedDeliveryOfVehicleTypes = new List <SelectListItem>();
                        vm.CRMShipper.DeliveryOfVehicleType.Split('|').Each((i, s) => {
                            selectedDeliveryOfVehicleTypes.Add(new SelectListItem()
                            {
                                Text = s, Value = s
                            });
                        });
                        vm.SelectedDeliveryOfVehicleTypes = selectedDeliveryOfVehicleTypes;
                    }

                    if (!string.IsNullOrEmpty(vm.CRMShipper.SixCard))
                    {
                        IList <SelectListItem> selectedSixCards = new List <SelectListItem>();
                        vm.CRMShipper.SixCard.Split('|').Each((i, s) =>
                        {
                            selectedSixCards.Add(new SelectListItem()
                            {
                                Text = s, Value = s
                            });
                        });
                        vm.SelectedSixCards = selectedSixCards;
                    }

                    if (!string.IsNullOrEmpty(vm.CRMShipper.TermialOfVehicleType))
                    {
                        IList <SelectListItem> selectedTermialOfVehicleTypes = new List <SelectListItem>();
                        vm.CRMShipper.TermialOfVehicleType.Split('|').Each((i, s) =>
                        {
                            selectedTermialOfVehicleTypes.Add(new SelectListItem()
                            {
                                Text = s, Value = s
                            });
                        });
                        vm.SelectedTermialOfVehicleTypes = selectedTermialOfVehicleTypes;
                    }

                    if (!string.IsNullOrEmpty(vm.CRMShipper.TransportMode))
                    {
                        IList <SelectListItem> selectedTransportModes = new List <SelectListItem>();
                        vm.CRMShipper.TransportMode.Split('|').Each((i, s) =>
                        {
                            selectedTransportModes.Add(new SelectListItem()
                            {
                                Text = s, Value = s
                            });
                        });
                        vm.SelectedTransportModes = selectedTransportModes;
                    }

                    if (!string.IsNullOrEmpty(vm.CRMShipper.TrunkOfVehicleType))
                    {
                        IList <SelectListItem> selectedTrunkOfVehicleTypes = new List <SelectListItem>();
                        vm.CRMShipper.TrunkOfVehicleType.Split('|').Each((i, s) =>
                        {
                            selectedTrunkOfVehicleTypes.Add(new SelectListItem()
                            {
                                Text = s, Value = s
                            });
                        });
                        vm.SelectedTrunkOfVehicleTypes = selectedTrunkOfVehicleTypes;
                    }

                    vm.CRMShipperCooperationCollection        = getCRMShipperResponse.Result.CRMShipperCooperationCollection;
                    vm.CRMShipperTransportationLineCollection = getCRMShipperResponse.Result.CRMShipperTransportationLineCollection;
                    vm.CRMShipperTerminalInfoCollection       = getCRMShipperResponse.Result.CRMShipperTerminalInfoCollection;

                    if (string.IsNullOrEmpty(vm.CRMShipper.Str3))
                    {
                        vm.CRMShipper.Str3 = Guid.NewGuid().ToString();
                    }

                    if (string.IsNullOrEmpty(vm.CRMShipper.AttachmentGroupID))
                    {
                        vm.CRMShipper.AttachmentGroupID = Guid.NewGuid().ToString();
                    }
                }

                if (!ViewType.HasValue)
                {
                    vm.ViewType = 0;
                }
                else
                {
                    vm.ViewType = ViewType.Value;
                }

                if (base.UserInfo.ProjectRoleID == 28)
                {
                    vm.ShowEditButton = true;
                }
                else
                {
                    vm.ShowEditButton = false;
                }
            }

            return(View(vm));
        }