Example #1
0
        public ActionResult NewReceiver(ReceiverViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                Receiver data = new Receiver();
                data.Name = model.Name;
                data.Country = model.Country;
                data.Province = model.Province;
                data.City = model.City;
                data.Address = model.Address;
                data.Contact = model.Contact;
                data.ContactTel = model.ContactTel;

                List<ReceiverDistance> listDistance = new List<ReceiverDistance>();
                if (model.Distances != null)
                {
                    foreach (ReceiverDistanceViewModel m in model.Distances)
                    {
                        ReceiverDistance d = new ReceiverDistance();
                        d.ReceiverName = model.Name;
                        d.StartCountry = m.StartCountry;
                        d.StartProvince = m.StartProvince;
                        d.StartCity = m.StartCity;
                        d.KM = m.KM;
                        listDistance.Add(d);
                    }
                }

                //保存数据
                string strErrText;
                DDSystem dd = new DDSystem();
                if (dd.InsertReceiver(data, listDistance, LoginAccountId, LoginStaffName, out strErrText) > 0)
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }