/// <summary>
 /// 广告位大小下拉框
 /// </summary>
 /// <param name="name">ViewData名称</param>
 /// <param name="size">当前选中的size</param>
 private void PositionSizeDropDownList(string name, string size)
 {
     List<SelectListItem> sizeItems = new List<SelectListItem>();
     IEnumerable<string> sizes = new AdvertisingService().GetAllPositionSize();
     foreach (var item in sizes)
     {
         sizeItems.Add(new SelectListItem { Text = item, Value = item });
     }
     ViewData[name] = new SelectList(sizeItems, "value", "text", size);
 }
        /// <summary>
        /// 将EditModel转换为广告位实体
        /// </summary>
        /// <returns></returns>
        public AdvertisingPosition AsAdvertisingPosition()
        {
            AdvertisingService advertisingService = new AdvertisingService();
            AdvertisingPosition position = advertisingService.GetPosition(PositionId);

            if (position == null)
            {
                position = AdvertisingPosition.New();
                position.PositionId = PositionId;
            }
            position.Description = Description ?? string.Empty;
            position.FeaturedImage = FeaturedImage ?? string.Empty;
            position.PresentAreaKey = PresentAreaKey;
            position.Height = Height;
            position.Width = Width;
            position.IsEnable = IsEnable;
            return position;
        }
Exemple #3
0
 /// <summary>
 /// 显示广告位下的广告
 /// </summary>
 /// <returns></returns>
 public ActionResult _AdvertisingPosition(long advertisingId)
 {
     Advertising advertising = new AdvertisingService().GetAdvertising(advertisingId);
     ViewData["advertising"] = advertising;
     return View();
 }
 /// <summary>
 /// 转化为数据库实体
 /// </summary>
 /// <returns></returns>
 public Advertising AsAdvertising()
 {
     AdvertisingService advertisingService = new AdvertisingService();
     Advertising advertising = null;
     if (this.AdvertisingId > 0)
     {
         advertising = advertisingService.GetAdvertising(this.AdvertisingId);
     }
     if (advertising == null)
     {
         advertising = Advertising.New();
     }
     advertising.AdvertisingType = this.AdvertisingType;
     switch (this.AdvertisingType)
     {
         case AdvertisingType.Image:
             {
                 if (isUploadImage)
                 {
                     advertising.AttachmentUrl = this.UploadImageFileName ?? string.Empty;
                 }
                 else
                 {
                     advertising.AttachmentUrl = this.NetImageUrl ?? string.Empty;
                 }
                 advertising.Url = this.ImageLinkedUrl ?? string.Empty;
                 advertising.TextStyle = string.Empty;
                 advertising.Body = string.Empty;
                 advertising.IsBlank = this.IsImageBlank;
                 advertising.Width = this.ImageWidth;
                 advertising.Height = this.ImageHeight;
             }
             break;
         case AdvertisingType.Script:
             {
                 advertising.Body = this.ScriptContent ?? string.Empty;
                 advertising.Url = string.Empty;
                 advertising.TextStyle = string.Empty;
                 advertising.AttachmentUrl = string.Empty;
                 advertising.IsBlank = true;
             }
             break;
         case AdvertisingType.Flash:
             {
                 advertising.AttachmentUrl = this.FlashUrl ?? string.Empty;
                 advertising.Body = string.Empty;
                 advertising.Url = string.Empty;
                 advertising.TextStyle = string.Empty;
                 advertising.IsBlank = true;
                 advertising.Width = this.FlashWidth;
                 advertising.Height = this.FlashHeight;
             }
             break;
         case AdvertisingType.Text:
             {
                 advertising.Body = this.TextContent ?? string.Empty;
                 advertising.Url = this.TextLinkedUrl ?? string.Empty;
                 advertising.TextStyle = this.TextStyle ?? string.Empty;
                 advertising.AttachmentUrl = string.Empty;
                 advertising.IsBlank = this.IsTextBlank;
             }
             break;
     }
     advertising.IsEnable = this.IsEnable;
     advertising.LastModified = DateTime.UtcNow;
     advertising.Name = this.Name ?? string.Empty;
     advertising.StartDate = this.StartDate;
     advertising.EndDate = this.EndDate;
     return advertising;
 }