示例#1
0
        public ActionResult AddAdvert(AdvertModel model)
        {
            if (Adverts.GetAdvertPositionById(model.AdPosId) == null)
            {
                ModelState.AddModelError("AdPosId", "广告位置不存在");
            }

            if (ModelState.IsValid)
            {
                AdvertInfo advertInfo = new AdvertInfo()
                {
                    ClickCount   = 0,
                    AdPosId      = model.AdPosId,
                    Type         = model.Type,
                    Title        = model.Title,
                    Body         = model.Body,
                    Url          = model.Url ?? "",
                    StartTime    = model.StartTime,
                    EndTime      = model.EndTime,
                    State        = model.State,
                    DisplayOrder = model.DisplayOrder
                };

                Adverts.CreateAdvert(advertInfo);
                AddAdminOperateLog("添加广告", "添加广告,广告为:" + model.Title);
                return(PromptView("广告添加成功"));
            }
            Load();
            return(View(model));
        }
示例#2
0
        public ActionResult EditAdvertPosition(int adPosId = -1)
        {
            AdvertPositionInfo advertPositionInfo = Adverts.GetAdvertPositionById(adPosId);

            if (advertPositionInfo == null)
            {
                return(PromptView("广告位置不存在"));
            }

            AdvertPositionModel model = new AdvertPositionModel();

            model.Title       = advertPositionInfo.Title;
            model.Description = advertPositionInfo.Description;

            ViewData["referer"] = SiteUtils.GetAdminRefererCookie();
            return(View(model));
        }
示例#3
0
        public ActionResult EditAdvertPosition(AdvertPositionModel model, int adPosId = -1)
        {
            AdvertPositionInfo advertPositionInfo = Adverts.GetAdvertPositionById(adPosId);

            if (advertPositionInfo == null)
            {
                return(PromptView("广告位置不存在"));
            }

            if (ModelState.IsValid)
            {
                advertPositionInfo.Title       = model.Title;
                advertPositionInfo.Description = model.Description ?? "";

                Adverts.UpdateAdvertPosition(advertPositionInfo);
                AddAdminOperateLog("修改广告位置", "修改广告位置,广告位置ID为:" + adPosId);
                return(PromptView("广告位置修改成功"));
            }

            ViewData["referer"] = SiteUtils.GetAdminRefererCookie();
            return(View(model));
        }