public ActionResult Add(OutDoorAdminViewModel model) { ServiceResult result = new ServiceResult(); var AreaCateArray = new List <int>(); var CrowdCateArray = new List <int>(); var IndustryCateArray = new List <int>(); var PurposeCateArray = new List <int>(); //if (!string.IsNullOrEmpty(model.AreaCate)) //{ // AreaCateArray = model.AreaCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //if (!string.IsNullOrEmpty(model.CrowdCate)) //{ // CrowdCateArray = model.CrowdCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //if (!string.IsNullOrEmpty(model.IndustryCate)) //{ // IndustryCateArray = model.IndustryCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //if (!string.IsNullOrEmpty(model.PurposeCate)) //{ // PurposeCateArray = model.PurposeCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} TempData["Service_Result"] = result; if (!ModelState.IsValid) { result.Message = "表单输入有误,请仔细填写表单!"; result.AddServiceError("表单输入有误,请仔细填写表单!"); } else { try { OutDoorService.Create(model); result.Message = "后台添加户外成功!"; return(RedirectToAction("index")); } catch (Exception ex) { result.Message = "后台添加户外失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("后台用户:" + CookieHelper.MemberID + "添加户外失败!", ex); } } //ViewBag.Data_CrowdCate = Utilities.GetSelectListData(CrowdCateService.GetALL(), x => x.ID, x => x.CateName, CrowdCateArray, false); //ViewBag.Data_IndustryCate = Utilities.GetSelectListData(IndustryCateService.GetALL(), x => x.ID, x => x.CateName, IndustryCateArray, false); //ViewBag.Data_PurposeCate = Utilities.GetSelectListData(PurposeCateService.GetALL(), x => x.ID, x => x.CateName, PurposeCateArray, false); //ViewBag.Data_AreaCate = Utilities.GetSelectListData(AreaCateService.GetALL(), x => x.ID, x => x.CateName, AreaCateArray, false); ViewBag.Data_FormatCode = Utilities.GetSelectListData(FormatCateService.GetALL(), x => x.ID, x => x.CateName, true); ViewBag.Data_PeriodCode = Utilities.GetSelectListData(PeriodCateService.GetALL(), x => x.ID, x => x.CateName, true); //ViewBag.Data_OwnerCode = Utilities.GetSelectListData(OwnerCateService.GetALL(), x => x.ID, x => x.CateName, false); return(View(model)); }
public ActionResult Edit(int id) { OutDoor entity = OutDoorService.GetALL() //.Include(x => x.AreaCate) //.Include(x => x.CrowdCate) //.Include(x => x.IndustryCate) //.Include(x => x.PurposeCate) .Single(x => x.ID == id); OutDoorAdminViewModel model = new OutDoorAdminViewModel() { Name = entity.Name, MemberID = entity.MemberID, MediaCode = entity.MediaCodeValue, CityCode = entity.CityCodeValue, //CredentialsImg = entity.CredentialsImg, MediaImg = entity.MediaImg, Description = entity.Description, Deadline = entity.Deadline, HasLight = entity.HasLight, //AreaCate = String.Join(",", entity.AreaCate.Select(x => x.ID)), //CrowdCate = String.Join(",", entity.CrowdCate.Select(x => x.ID)), //IndustryCate = String.Join(",", entity.IndustryCate.Select(x => x.ID)), //PurposeCate = String.Join(",", entity.PurposeCate.Select(x => x.ID)), FormatCode = entity.FormatCode, //OwnerCode = entity.OwnerCode, Price = entity.Price, RealPrice = entity.RealPrice, //PriceExten = entity.PriceExten, ID = entity.ID, Location = entity.Location, //PeriodCode = entity.PeriodCode, Position = entity.Lat + "|" + entity.Lng, TrafficAuto = entity.TrafficAuto, TrafficPerson = entity.TrafficPerson, VideoUrl = entity.VideoUrl }; if (entity.HasLight) { model.LightTime = entity.LightStart + "|" + entity.LightEnd; } if (entity.IsRegular) { model.MediaArea = "true|" + entity.Wdith + "|" + entity.Height + "|" + entity.TotalFaces; } else { model.MediaArea = entity.IrRegularArea; } var AreaCateArray = new List <int>(); var CrowdCateArray = new List <int>(); var IndustryCateArray = new List <int>(); var PurposeCateArray = new List <int>(); //if (!string.IsNullOrEmpty(model.AreaCate)) //{ // AreaCateArray = model.AreaCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //if (!string.IsNullOrEmpty(model.CrowdCate)) //{ // CrowdCateArray = model.CrowdCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //if (!string.IsNullOrEmpty(model.IndustryCate)) //{ // IndustryCateArray = model.IndustryCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //if (!string.IsNullOrEmpty(model.PurposeCate)) //{ // PurposeCateArray = model.PurposeCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //ViewBag.Data_CrowdCate = Utilities.GetSelectListData(CrowdCateService.GetALL(), x => x.ID, x => x.CateName, CrowdCateArray, false); //ViewBag.Data_IndustryCate = Utilities.GetSelectListData(IndustryCateService.GetALL(), x => x.ID, x => x.CateName, IndustryCateArray, false); //ViewBag.Data_PurposeCate = Utilities.GetSelectListData(PurposeCateService.GetALL(), x => x.ID, x => x.CateName, PurposeCateArray, false); //ViewBag.Data_AreaCate = Utilities.GetSelectListData(AreaCateService.GetALL(), x => x.ID, x => x.CateName, AreaCateArray, false); ViewBag.Data_FormatCode = Utilities.GetSelectListData(FormatCateService.GetALL(), x => x.ID, x => x.CateName, model.FormatCode, true); //ViewBag.Data_PeriodCode = Utilities.GetSelectListData(PeriodCateService.GetALL(), x => x.ID, x => x.CateName, model.PeriodCode, true); //ViewBag.Data_OwnerCode = Utilities.GetSelectListData(OwnerCateService.GetALL(), x => x.ID, x => x.CateName, model.OwnerCode, false); return(View(model)); }
public OutDoor Update(OutDoorAdminViewModel model) { OutDoor od = GetALL() //.Include(x => x.AreaCate) //.Include(x => x.CrowdCate) //.Include(x => x.IndustryCate) //.Include(x => x.PurposeCate) .Single(x => x.ID == model.ID); db.Attach <OutDoor>(od); od.CityCodeValue = model.CityCode; od.CityCode = Utilities.GetCascadingId(model.CityCode); //od.PeriodCode = model.PeriodCode; od.MemberID = model.MemberID; od.MediaCodeValue = model.MediaCode; od.MediaCode = Utilities.GetCascadingId(model.MediaCode); od.FormatCode = model.FormatCode; if (string.IsNullOrEmpty(model.Description)) { od.Description = string.Empty; } else { od.Description = model.Description; } od.HasLight = model.HasLight; od.LastIP = HttpHelper.IP; od.LastTime = DateTime.Now; od.Lat = Convert.ToDouble(model.Position.Split('|')[0]); od.Lng = Convert.ToDouble(model.Position.Split('|')[1]); od.Location = model.Location; od.Name = model.Name; od.Price = model.Price; od.RealPrice = model.RealPrice; //od.PriceExten = model.PriceExten; od.TrafficAuto = model.TrafficAuto; od.TrafficPerson = model.TrafficPerson; od.VideoUrl = model.VideoUrl; od.Unapprovedlog = string.Empty; od.Deadline = model.Deadline; //MediaArea参数设置 if (!string.IsNullOrEmpty(model.MediaArea)) { var areaParams = model.MediaArea.Split('|'); var IsRegular = Convert.ToBoolean(areaParams[0]); if (IsRegular) { od.IsRegular = true; od.Wdith = Convert.ToDecimal(areaParams[1]); od.Height = Convert.ToDecimal(areaParams[2]); od.TotalFaces = Convert.ToInt32(areaParams[3]); od.TotalArea = od.Wdith * od.Height * od.TotalFaces; } else { od.IsRegular = false; od.IrRegularArea = model.MediaArea; od.TotalArea = 0; for (var i = 1; i < areaParams.Length; i += 2) { od.TotalArea += (Convert.ToDecimal(areaParams[i]) * Convert.ToDecimal(areaParams[i + 1])); } od.TotalFaces = areaParams.Length / 2; } } //Light Time 设置 if (model.HasLight) { if (!string.IsNullOrEmpty(model.LightTime) && model.LightTime.Split('|').Length == 2) { var LightTime = model.LightTime.Split('|'); od.LightStart = Convert.ToInt32(LightTime[0]); od.LightEnd = Convert.ToInt32(LightTime[1]); } } //MediaImg 设置 od.MediaImg = model.MediaImg; od.MediaFoucsImg = UIHelper.GetImgUrl(model.MediaImg.Split(',')[0], ImgUrlType.Img120); //od.CredentialsImg = model.CredentialsImg; //var AreaCateArray = new List<int>(); //if (string.IsNullOrEmpty(model.AreaCate)) //{ // od.AreaCate = new List<AreaCate>(); //} //else //{ // AreaCateArray = model.AreaCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); // var AreaCateList = AreaCateService.GetALL().Where(x => AreaCateArray.Contains(x.ID)); // var currentAreaCateArray = od.AreaCate.Select(x => x.ID).ToList(); // foreach (AreaCate ac in AreaCateService.GetALL()) // { // if (AreaCateArray.Contains(ac.ID)) // { // if (!currentAreaCateArray.Contains(ac.ID)) // { // od.AreaCate.Add(ac); // } // } // else // { // if (currentAreaCateArray.Contains(ac.ID)) // { // od.AreaCate.Remove(ac); // } // } // } //} //var CrowdCateArray = new List<int>(); //if (string.IsNullOrEmpty(model.CrowdCate)) //{ // od.CrowdCate = new List<CrowdCate>(); //} //else //{ // CrowdCateArray = model.CrowdCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); // var CrowdCateList = CrowdCateService.GetALL().Where(x => CrowdCateArray.Contains(x.ID)); // var currentCrowdCateArray = od.CrowdCate.Select(x => x.ID).ToList(); // foreach (CrowdCate ac in CrowdCateService.GetALL()) // { // if (CrowdCateArray.Contains(ac.ID)) // { // if (!currentCrowdCateArray.Contains(ac.ID)) // { // od.CrowdCate.Add(ac); // } // } // else // { // if (currentCrowdCateArray.Contains(ac.ID)) // { // od.CrowdCate.Remove(ac); // } // } // } //} //var IndustryCateArray = new List<int>(); //if (string.IsNullOrEmpty(model.IndustryCate)) //{ // od.IndustryCate = new List<IndustryCate>(); //} //else //{ // IndustryCateArray = model.IndustryCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); // var IndustryCateList = IndustryCateService.GetALL().Where(x => IndustryCateArray.Contains(x.ID)); // var currentIndustryCateArray = od.IndustryCate.Select(x => x.ID).ToList(); // foreach (IndustryCate ac in IndustryCateService.GetALL()) // { // if (IndustryCateArray.Contains(ac.ID)) // { // if (!currentIndustryCateArray.Contains(ac.ID)) // { // od.IndustryCate.Add(ac); // } // } // else // { // if (currentIndustryCateArray.Contains(ac.ID)) // { // od.IndustryCate.Remove(ac); // } // } // } //} //var PurposeCateArray = new List<int>(); //if (string.IsNullOrEmpty(model.PurposeCate)) //{ // od.PurposeCate = new List<PurposeCate>(); //} //else //{ // PurposeCateArray = model.PurposeCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); // var PurposeCateList = PurposeCateService.GetALL().Where(x => PurposeCateArray.Contains(x.ID)); // var currentPurposeCateArray = od.PurposeCate.Select(x => x.ID).ToList(); // foreach (PurposeCate ac in PurposeCateService.GetALL()) // { // if (PurposeCateArray.Contains(ac.ID)) // { // if (!currentPurposeCateArray.Contains(ac.ID)) // { // od.PurposeCate.Add(ac); // } // } // else // { // if (currentPurposeCateArray.Contains(ac.ID)) // { // od.PurposeCate.Remove(ac); // } // } // } //} //set OutDoor Status 待审核状态 od.Status = (int)OutDoorStatus.PreVerify; db.Commit(); OutDoorLuceneService.UpdateIndex(model.ID.ToString()); return(od); }