Пример #1
0
 public ActionResult add(AdListAddViewModel _adlist)
 {
     if (ModelState.IsValid)
     {
         HttpPostedFileBase pfb     = Request.Files["fileIMG"];
         string             outPath = "";
         string             msg     = UploadImg.Upload(pfb, out outPath);
         if (msg != "")
         {
         }
         AdList model = new AdList()
         {
             AdPositionId = _adlist.AdPositionId,
             Img          = _adlist.Img,
             IsShow       = _adlist.IsShow,
             Src          = _adlist.Src,
             Title        = _adlist.Title
         };
         AdPosition position = adpositionBll.Find(p => p.Id == model.AdPositionId);
         //判断广告数量
         int count = adlistBll.Count(a => a.AdPositionId == model.AdPositionId);
         if (count >= position.Count)
         {
             ModelState.AddModelError("", "广告数量已满!");
         }
         else
         {
             model = adlistBll.Add(model);
             if (model.Id > 0)
             {
                 return(RedirectToAction("list"));//Response.Write("添加成功");
             }
             else
             {
                 ModelState.AddModelError("", "添加失败!");
             }
         }
     }
     return(View(_adlist));
 }
Пример #2
0
        public ActionResult Upload()
        {
            HttpPostedFileBase postedFile = Request.Files["file_data"];

            if (postedFile == null)
            {
                return(JsAlert("没有选择文件"));
            }
            UploadImg.FileModel filemodel  = UploadImg.Upload(postedFile);
            FileEntity          fileEntity = new FileEntity()
            {
                F_FileMax       = Convert.ToDouble(filemodel.FileMax) / 1024 + "kb",
                F_FileName      = filemodel.FileName,
                F_RealName      = filemodel.RealName,
                F_CreatorTime   = DateTime.Now,
                F_CreatorUserId = OperatorProvider.Provider.GetCurrent().UserId,
                F_UploadDate    = DateTime.Now,
                F_UploadUser    = OperatorProvider.Provider.GetCurrent().UserId
            };

            fileApp.SubmitForm(fileEntity, "");
            return(Success("操作成功。"));
        }