Exemplo n.º 1
0
        public ActionResult Details(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);

            OutDoorViewModel model = new OutDoorViewModel()
            {
                Name = entity.Name,
                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);
            var cityIds = model.CityCode.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            var cityValues = CityCateService.GetALL().Where(x => cityIds.Contains(x.ID)).Select(x => x.CateName).ToList();
            ViewBag.Data_CityCode = cityValues;

            var meidaIds = model.MediaCode.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            var meidaValues = MediaCateService.GetALL().Where(x => meidaIds.Contains(x.ID)).Select(x => x.CateName).ToList();
            ViewBag.Data_MediaCode = meidaValues;
            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult Edit(OutDoorViewModel model)
        {
            ViewBag.MenuItem = "media-list";
            if (!CheckMemberStatus())
            {
                return Redirect(Url.Action("openbiz", "register"));
            }

            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            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();
            //}

            if (!ModelState.IsValid)
            {
                result.Message = "表单输入有误,请仔细填写表单!";
                result.AddServiceError("表单输入有误,请仔细填写表单!");
            }
            else
            {
                try
                {
                    OutDoorService.Update(model);
                    result.Message = "编辑户外成功!";
                    return RedirectToAction("preverify");
                }
                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);
        }
Exemplo n.º 3
0
        public OutDoor Update(OutDoorViewModel 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.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;
        }
Exemplo n.º 4
0
        public ActionResult Edit(int id)
        {
            ViewBag.MenuItem = "media-list";
            if (!CheckMemberStatus())
            {
                return Redirect(Url.Action("openbiz", "register"));
            }
            if (OutDoorService.GetALL().Any(x => x.ID == id && x.MemberID == CookieHelper.MemberID))
            {
                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);

                OutDoorViewModel model = new OutDoorViewModel()
                {
                    Name = entity.Name,
                    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);
            }
            else
            {
                return Content("<script>alert('非法操作!');window.history.go(-1);</script>");
            }
        }
Exemplo n.º 5
0
        public OutDoor Create(OutDoorViewModel model)
        {
            OutDoor od = new OutDoor();
            od.AddIP = HttpHelper.IP;
            od.AddTime = DateTime.Now;
            od.CityCodeValue = model.CityCode;
            od.CityCode = Utilities.GetCascadingId(model.CityCode);
            if (string.IsNullOrEmpty(model.Description))
            {
                od.Description = string.Empty;
            }
            else
            {
                od.Description = model.Description;
            }
            od.FormatCode = model.FormatCode;
            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.MemberID = CookieHelper.MemberID;
            od.MediaCodeValue = model.MediaCode;
            od.MediaCode = Utilities.GetCascadingId(model.MediaCode);
            od.Name = model.Name;
            //od.PeriodCode = model.PeriodCode;
            od.PeriodCode = 3;
            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;

            //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);

            //补充信息设置
            //if (!string.IsNullOrEmpty(model.AreaCate))
            //{
            //    var AreaCateArray = model.AreaCate.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            //    var AreaCateList = AreaCateService.GetALL().Where(x => AreaCateArray.Contains(x.ID));
            //    od.AreaCate.AddRange(AreaCateList);
            //}

            //if (!string.IsNullOrEmpty(model.IndustryCate))
            //{
            //    var IndustryCateArray = model.IndustryCate.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            //    var IndustryCateList = IndustryCateService.GetALL().Where(x => IndustryCateArray.Contains(x.ID));
            //    od.IndustryCate.AddRange(IndustryCateList);
            //}

            //if (!string.IsNullOrEmpty(model.CrowdCate))
            //{
            //    var CrowdCateArray = model.CrowdCate.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            //    var CrowdCateList = CrowdCateService.GetALL().Where(x => CrowdCateArray.Contains(x.ID));
            //    od.CrowdCate.AddRange(CrowdCateList);
            //}

            //if (!string.IsNullOrEmpty(model.PurposeCate))
            //{
            //    var PurposeCateArray = model.PurposeCate.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            //    var PurposeCateList = PurposeCateService.GetALL().Where(x => PurposeCateArray.Contains(x.ID));
            //    od.PurposeCate.AddRange(PurposeCateList);
            //}

            //认证信息设置
            //od.OwnerCode = model.OwnerCode;
            //if (!string.IsNullOrEmpty(model.CredentialsImg))
            //{
            //    od.CredentialsImg = model.CredentialsImg;
            //}

            //od.OwnerCode = model.OwnerCode;
            od.Deadline = model.Deadline;

            //set OutDoor Status 待审核状态
            od.Status = (int)OutDoorStatus.PreVerify;

            db.Add<OutDoor>(od);
            db.Commit();
            return od;
        }