Example #1
0
        public ActionResult ModifyCarrier(CarrierViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                Carrier data = new Carrier();
                data.Id = model.Id;
                data.Name = model.Name;
                data.BusinessType = model.BusinessType;
                data.PaymentType = model.PaymentType;

                List<CarrierCar> listCar = new List<CarrierCar>();
                if (model.Cars != null)
                {
                    foreach (CarrierCarViewModel m in model.Cars)
                    {
                        CarrierCar c = new CarrierCar();
                        c.Id = m.Id;
                        c.CarrierId = m.CarrierId;
                        c.CarNo = m.CarNo;
                        c.TrailerNo = m.TrailerNo;
                        c.CarryingCapacity = m.CarryingCapacity;
                        listCar.Add(c);
                    }
                }

                List<CarrierDriver> listDriver = new List<CarrierDriver>();
                if (model.Drivers != null)
                {
                    foreach (CarrierDriverViewModel m in model.Drivers)
                    {
                        CarrierDriver d = new CarrierDriver();
                        d.CarrierId = m.CarrierId;
                        d.CarNo = m.CarNo;
                        d.Name = m.Name;
                        d.LicenseNo = m.LicenseNo;
                        d.MobileTel = m.MobileTel;
                        d.HomeTel = m.HomeTel;
                        listDriver.Add(d);
                    }
                }

                List<CarrierSettlementExpression> listExpression = new List<CarrierSettlementExpression>();
                if (model.SettlementExpressions != null)
                {
                    foreach (CarrierSettlementExpressionViewModel m in model.SettlementExpressions)
                    {
                        CarrierSettlementExpression e = new CarrierSettlementExpression();
                        e.CarrierId = m.CarrierId;
                        e.PlanType = m.PlanType;
                        e.TransportChargeExpression = m.TransportChargeExpression;
                        e.TransportPriceExpression = m.TransportPriceExpression;
                        listExpression.Add(e);
                    }
                }

                List<CarrierTransportPrice> listPrice = new List<CarrierTransportPrice>();
                if (model.TransportPrices != null)
                {
                    foreach (CarrierTransportPriceViewModel m in model.TransportPrices)
                    {
                        CarrierTransportPrice p = new CarrierTransportPrice();
                        p.CarrierId = m.CarrierId;
                        p.StartCountry = m.StartCountry;
                        p.StartProvince = m.StartProvince;
                        p.StartCity = m.StartCity;
                        p.DestCountry = m.DestCountry;
                        p.DestProvince = m.DestProvince;
                        p.DestCity = m.DestCity;
                        p.PlanType = m.PlanType;
                        p.StartTime = DateTime.Parse(m.StartTime);
                        p.EndTime = DateTime.Parse(m.EndTime);
                        p.TransportPrice = m.TransportPrice;
                        listPrice.Add(p);
                    }
                }

                //保存数据
                string strErrText;
                DDSystem dd = new DDSystem();
                if (dd.UpdateCarrier(data, listCar, listDriver, listExpression, listPrice, LoginAccountId, LoginStaffName, out strErrText))
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }