Exemplo n.º 1
0
        public ActionResult Add(OutDoorViewModel model)
        {
            ViewBag.MenuItem = "media-publish";
            if (!CheckMemberStatus())
            {
                return Redirect(Url.Action("openbiz", "register"));
            }
            ServiceResult result = new ServiceResult();
            var AreaAttArray = new List<int>();
            TempData["Service_Result"] = result;

            if (!ModelState.IsValid)
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");
            }
            else
            {
                try
                {
                    AreaAttArray = model.AreaAtt.Split(',').Select(x => Convert.ToInt32(x)).ToList();
                    outDoorService.Create(model);
                    result.Message = "添加户外成功!";
                    return RedirectToAction("preverify");
                }
                catch (DbEntityValidationException ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                }

            }

            ViewBag.Data_AreaAtt = areaAttService.GetSelectList(AreaAttArray);
            return View(model);
        }
Exemplo n.º 2
0
        public OutDoor Create(OutDoorViewModel model)
        {
            int MemberID = Convert.ToInt32(CookieHelper.UID);
            OutDoor od = new OutDoor();
            od.AddIP = HttpHelper.IP;
            od.AddTime = DateTime.Now;
            od.CityCode = model.CityCode;
            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 = MemberID;
            od.MeidaCode = model.MeidaCode;
            od.Name = model.Name;
            od.PeriodCode = model.PeriodCode;
            od.Price = model.Price;
            od.PriceExten = model.PriceExten;
            od.SeoDes = model.Description.Length > 250 ? model.Description.Substring(0, 249) : model.Description;

            od.SeoTitle = model.Name;

            od.Seokeywords = model.Name;

            od.TrafficAuto = model.TrafficAuto;
            od.TrafficPerson = model.TrafficPerson;
            od.VideoUrl = model.VideoUrl;
            od.Unapprovedlog = string.Empty;

            //Area参数设置
            if (!string.IsNullOrEmpty(model.Area) && model.Area.Split('|').Length == 3)
            {
                var areaArray = model.Area.Split('|');
                od.Wdith = Convert.ToDecimal(areaArray[0]);
                od.Height = Convert.ToDecimal(areaArray[1]);
                od.TotalFaces = Convert.ToInt32(areaArray[2]);
            }
            //Light Time 设置
            if (model.HasLight)
            {
                if (!string.IsNullOrEmpty(model.LightTime) && model.LightTime.Split('|').Length == 2)
                {
                    var LightTime = model.LightTime.Split('|');
                    od.LightStrat = LightTime[0];
                    od.LightEnd = LightTime[1];
                }
            }

            MediaImg media = new MediaImg()
            {
                FocusImgUrl = UIHelper.GetImgUrl(model.MediaImg.Split(',')[0], ImgUrlType.Img120),
                ImgUrls = model.MediaImg,
                MemberID = MemberID
            };
            od.MediaImg = media;

            var AreaAttArray = model.AreaAtt.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            var AreaAttList = AreaAttService.GetList(AreaAttArray);

            od.AreaAtt.AddRange(AreaAttList);

            CredentialsImg credent = new CredentialsImg()
            {
                FocusImgUrl = UIHelper.GetImgUrl(model.CredentialsImg.Split(',')[0], ImgUrlType.Img120),
                ImgUrls = model.CredentialsImg,
                MemberID = MemberID
            };

            od.OwnerCode = model.OwnerCode;
            od.CredentialsImg = credent;
            od.Deadline = model.Deadline;

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

            DB_Service.Add<OutDoor>(od);
            DB_Service.Commit();

            return od;
        }
Exemplo n.º 3
0
        public OutDoor Update(OutDoorViewModel model)
        {
            int MemberID = Convert.ToInt32(CookieHelper.UID);
            OutDoor od = IncludeFind(model.MediaID);
            DB_Service.Attach<OutDoor>(od);
            od.CityCode = model.CityCode;
            od.PeriodCode = model.PeriodCode;
            od.MeidaCode = model.MeidaCode;
            od.FormatCode = model.FormatCode;

            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.MemberID = MemberID;
            od.Name = model.Name;
            od.Price = model.Price;
            od.PriceExten = model.PriceExten;
            od.SeoDes = model.Description.Length > 250 ? model.Description.Substring(0, 249) : model.Description;

            od.SeoTitle = model.Name;

            od.Seokeywords = model.Name;

            od.TrafficAuto = model.TrafficAuto;
            od.TrafficPerson = model.TrafficPerson;
            od.VideoUrl = model.VideoUrl;
            od.Unapprovedlog = string.Empty;

            //Area参数设置
            if (!string.IsNullOrEmpty(model.Area) && model.Area.Split('|').Length == 3)
            {
                var areaArray = model.Area.Split('|');
                od.Wdith = Convert.ToDecimal(areaArray[0]);
                od.Height = Convert.ToDecimal(areaArray[1]);
                od.TotalFaces = Convert.ToInt32(areaArray[2]);
            }
            //Light Time 设置
            if (model.HasLight)
            {
                if (!string.IsNullOrEmpty(model.LightTime) && model.LightTime.Split('|').Length == 2)
                {
                    var LightTime = model.LightTime.Split('|');
                    od.LightStrat = LightTime[0];
                    od.LightEnd = LightTime[1];
                }
            }
            od.MediaImg.ImgUrls = model.MediaImg;
            od.MediaImg.FocusImgUrl = UIHelper.GetImgUrl(model.MediaImg.Split(',')[0], ImgUrlType.Img120);

            od.CredentialsImg.ImgUrls = model.CredentialsImg;
            od.CredentialsImg.FocusImgUrl = UIHelper.GetImgUrl(model.CredentialsImg.Split(',')[0], ImgUrlType.Img120);
            var AreaAttArray = model.AreaAtt.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            if (AreaAttArray.Count == 0)
            {
                od.AreaAtt = new List<AreaAtt>();
            }
            else
            {
                var AreaAttList = AreaAttService.GetList(AreaAttArray);
                var currentAreaAttArray = od.AreaAtt.Select(x => x.ID).ToList();

                foreach (AreaAtt rl in AreaAttService.GetList())
                {
                    if (AreaAttArray.Contains(rl.ID))
                    {
                        if (!currentAreaAttArray.Contains(rl.ID))
                        {
                            od.AreaAtt.Add(rl);
                        }
                    }
                    else
                    {
                        if (currentAreaAttArray.Contains(rl.ID))
                        {
                            od.AreaAtt.Remove(rl);
                        }
                    }
                }
            }

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

            DB_Service.Commit();

            return od;
        }
Exemplo n.º 4
0
 public OutDoorViewModel GetOutDoorViewModel(int MediaID)
 {
     OutDoorViewModel odv = new OutDoorViewModel();
     int MemberID = Convert.ToInt32(CookieHelper.UID);
     OutDoor od = new OutDoor();
     od = IncludeFind(MediaID);
     odv.MediaID = od.MediaID;
     odv.AreaAtt = String.Join(",", od.AreaAtt.Select(x => x.ID));
     odv.CityCode = od.CityCode;
     odv.CredentialsImg = od.CredentialsImg.ImgUrls;
     odv.Deadline = od.Deadline;
     odv.Description = od.Description;
     //odv.EndTime = DateTime.Now;
     //odv.StartTime = DateTime.Now;
     odv.TrafficAuto = od.TrafficAuto;
     odv.TrafficPerson = od.TrafficPerson;
     odv.FormatCode = od.FormatCode;
     odv.Location = od.Location;
     odv.MediaImg = od.MediaImg.ImgUrls;
     odv.VideoUrl = od.VideoUrl;
     odv.MeidaCode = od.MeidaCode;
     odv.Name = od.Name;
     odv.OwnerCode = od.OwnerCode;
     odv.PeriodCode = od.PeriodCode;
     odv.Position = od.Lat + "|" + od.Lng;
     odv.Price = od.Price;
     odv.PriceExten = od.PriceExten;
     odv.Area = od.Wdith + "|" + od.Height + "|" + od.TotalFaces;
     odv.HasLight = od.HasLight;
     if (od.HasLight)
     {
         odv.LightTime = od.LightStrat + "|" + od.LightEnd;
     }
     return odv;
 }