Example #1
0
        public ActionResult Create(int?id, CustomerModel vm, int?ViewType)
        {
            vm.ViewType = ViewType != null ? (int)ViewType : 2;

            var segments = new SegmentService().GetSegmentsByCondition(new GetSegmentsByConditionRequest()
            {
                Name = "", State = true
            }).Result;

            vm.Segments = segments.Select(s => new SelectListItem()
            {
                Value = s.ID.ToString(), Text = s.Name + "------>>详情>>" + s.Description
            });
            if (id != null && id > 0)
            {
                string segmentId = new SegmentService().GetSegmentByCursterId((int)base.UserInfo.ProjectID, (int)id).Result;
                vm.SelectedCustomerOrShipperSegment = long.Parse(segmentId);
                CustomerService customer = new CustomerService();
                Customer        cus      = customer.selectCustomer((int)id);
                vm.ConvertDesc(cus);
            }
            else
            {
                vm.State = true;
            }

            return(View(vm));
        }
Example #2
0
        public ActionResult Create(CustomerModel vm)
        {
            CustomerService  service  = new CustomerService();
            IList <Customer> customer = new List <Customer>();

            var segments = new SegmentService().GetSegmentsByCondition(new GetSegmentsByConditionRequest()
            {
                Name = "", State = true
            }).Result;

            vm.Segments = segments.Select(s => new SelectListItem()
            {
                Value = s.ID.ToString(), Text = s.Name + "------>>详情>>" + s.Description
            });
            vm.Types = vm.StoreStatus > 0 ? 1 : 0;
            customer.Add(vm.Convert());
            Response <IEnumerable <Customer> > response = service.AddCustomer(new AddCustomerRequest()
            {
                customers = customer
            }, base.UserInfo.ID.ToString(), base.UserInfo.Name, (int)base.UserInfo.ProjectID, vm.SelectedCustomerOrShipperSegment.ToString() == "" ? 0 : (int)vm.SelectedCustomerOrShipperSegment);

            if (vm.ID > 0)
            {
                Customer cus = service.selectCustomer((int)vm.ID);
                vm.ConvertDesc(cus);
            }

            if (response.IsSuccess)
            {
                ApplicationConfigHelper.RefreshApplicationCustomers();
                ApplicationConfigHelper.RefreshGetApplicationCustomer();
                ApplicationConfigHelper.RefreshCustomers();
                if (vm.StoreType > 1)
                {
                    ViewBag.Message = response.Result.Select(c => c.ID).FirstOrDefault().ToString();
                }
                else
                {
                    ViewBag.Message = "0";
                }
            }
            return(View(vm));
        }