Пример #1
0
        public ActionResult CustFileUpdate(TS_CUSTFILEDTO cfDto)
        {
            //EF实体转换DTO
            cfDto.Title    = " 客户档案修改";
            cfDto.AreaMaxs = service.GetAreaMax();
            if (!ModelState.IsValid)
            {
                return(View(cfDto));
            }

            if (cfDto.OperationType == 1)
            {
                if (cfDto.CustAddrs == null)
                {
                    cfDto.CustAddrs = new List <TS_CUSTADDRDTO>();
                }

                if (cfDto.CustAddrs.Count > 0)
                {
                    foreach (var item in cfDto.CustAddrs)
                    {
                        item.N_ISDEFAULT = 0;
                    }
                }

                TS_CUSTADDRDTO addr = new TS_CUSTADDRDTO();
                addr.C_CUST_ID   = cfDto.C_ID;
                addr.N_ISDEFAULT = 1;
                cfDto.CustAddrs.Add(addr);
                return(View(cfDto));
            }

            else if (cfDto.OperationType == 2)
            {
                if (cfDto.CustTots == null)
                {
                    cfDto.CustTots = new List <TS_CUSTOTCOMPANYDTO>();
                }

                if (cfDto.CustTots.Count > 0)
                {
                    foreach (var item in cfDto.CustTots)
                    {
                        item.N_ISDEFAULT = 0;
                    }
                }

                TS_CUSTOTCOMPANYDTO tot = new TS_CUSTOTCOMPANYDTO();
                tot.C_CUST_ID   = cfDto.C_ID;
                tot.N_ISDEFAULT = 1;
                cfDto.CustTots.Add(tot);
                return(View(cfDto));
            }

            if (cfDto.OperationType == 3)
            {
                service.CustFileUpdate(cfDto);
                service.SaveCustAddr(cfDto);
                service.SaveCustTot(cfDto);
                cfDto.ResultType = 1;
                return(View(cfDto));
            }

            return(View(cfDto));
        }