コード例 #1
0
ファイル: SchemeService.cs プロジェクト: navy235/7980Site
 public void Update(Scheme model)
 {
     var target = Find(model.ID);
     db.Attach<Scheme>(target);
     target.Name = model.Name;
     target.LastTime = DateTime.Now;
     target.Description = model.Description;
     db.Commit();
 }
コード例 #2
0
ファイル: SchemeController.cs プロジェクト: navy235/7980Site
 public ActionResult Edit(SchemeAddViewModel model)
 {
     ViewBag.MenuItem = "scheme-media";
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             var entity = new Scheme();
             entity.ID = model.ID;
             entity.Name = model.Name;
             entity.Description = model.Description;
             SchemeService.Update(entity);
             result.Message = "媒体方案修改成功!";
             return Redirect(Url.Action("index"));
         }
         catch (Exception ex)
         {
             result.Message = Utilities.GetInnerMostException(ex);
             result.AddServiceError(result.Message);
             LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "媒体方案修改失败!", ex);
         }
     }
     else
     {
         result.Message = "表单输入有误!";
         result.AddServiceError("表单输入有误!");
     }
     return View(model);
 }
コード例 #3
0
ファイル: SchemeController.cs プロジェクト: navy235/7980Site
        public ActionResult Add(SchemeAddViewModel model)
        {
            ViewBag.MenuItem = "scheme-add";
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    var memberID = Convert.ToInt32(CookieHelper.UID);

                    Scheme entity = new Scheme()
                    {
                        Name = model.Name,
                        Description = model.Description,
                        MemberID = memberID,
                        AddTime = DateTime.Now,
                        LastTime = DateTime.Now,
                    };
                    SchemeService.Create(entity);
                    result.Message = "媒体方案保存成功!";
                    return Redirect(Url.Action("index"));
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "媒体方案保存失败!", ex);
                }
            }
            else
            {
                result.Message = "表单输入有误!";
                result.AddServiceError("表单输入有误!");
            }
            return View(model);
        }
コード例 #4
0
ファイル: SchemeService.cs プロジェクト: navy235/7980Site
 public void Delete(Scheme model)
 {
     var target = Find(model.ID);
     db.Remove<Scheme>(target);
     db.Commit();
 }
コード例 #5
0
ファイル: SchemeService.cs プロジェクト: navy235/7980Site
 public void Create(Scheme model)
 {
     db.Add<Scheme>(model);
     db.Commit();
 }
コード例 #6
0
ファイル: FanganController.cs プロジェクト: navy235/7980Site
        public ActionResult Download(int periodNumber, int periodCate, string mediaIds, string dq)
        {
            var idList = Utilities.GetIdList(mediaIds);
            var list = new List<LinkItem>();
            var currentPrice = 0m;
            if (idList.Any())
            {
                list = OutDoorLuceneService.Search(idList);
                var scheme = new Scheme()
                {
                    AddTime = DateTime.Now,
                    Description = ConfigSetting.SiteName + "方案生成",
                    Name = ConfigSetting.SiteName + "方案生成",
                    ID = 0
                };
                var model = new SchemePrintViewModel()
                  {
                      ID = scheme.ID,
                      Medias = list,
                      AddTime = scheme.AddTime,
                      Description = scheme.Description,
                      Name = scheme.Name
                  };
                var day = periodNumber * periodCate;
                foreach (var item in list)
                {
                    currentPrice += ((item.Price / 365) * day);
                }
                model.TotalPrice = currentPrice.ToString("F2");

                model.DqDesc = Convert.ToDateTime(dq).ToString("yyyy-MM-dd")
            + " 至 " + Convert.ToDateTime(dq).AddDays(day).ToString("yyyy-MM-dd");
                var html = Utilities.RenderPartialToString(this.ControllerContext,
                    "download",
                    new ViewDataDictionary(model),
                    new TempDataDictionary());
                byte[] data = System.Text.Encoding.UTF8.GetBytes(html);
                return File(data, "text/html", Guid.NewGuid() + ".html");
            }
            else
            {
                return RedirectToAction("index");
            }
        }
コード例 #7
0
ファイル: FanganController.cs プロジェクト: navy235/7980Site
 public ActionResult Print(int periodNumber, int periodCate, string mediaIds, string dq)
 {
     var idList = Utilities.GetIdList(mediaIds);
     var list = new List<LinkItem>();
     var currentPrice = 0m;
     if (idList.Any())
     {
         list = OutDoorLuceneService.Search(idList);
         var scheme = new Scheme()
         {
             AddTime = DateTime.Now,
             Description = ConfigSetting.SiteName + "方案生成",
             Name = ConfigSetting.SiteName + "方案生成",
             ID = 0
         };
         var model = new SchemePrintViewModel()
         {
             ID = scheme.ID,
             Medias = list,
             AddTime = scheme.AddTime,
             Description = scheme.Description,
             Name = scheme.Name
         };
         var day = periodNumber * periodCate;
         foreach (var item in list)
         {
             currentPrice += ((item.Price / 365) * day);
         }
         ViewBag.currentPrice = currentPrice.ToString("F2");
         model.DqDesc = Convert.ToDateTime(dq).ToString("yyyy-MM-dd")
       + " 至 " + Convert.ToDateTime(dq).AddDays(day).ToString("yyyy-MM-dd");
         return View(model);
     }
     else
     {
         return RedirectToAction("index");
     }
 }
コード例 #8
0
 public ActionResult AddScheme(AddSchemeViewModel model)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         SchemeItem entity = new SchemeItem();
         entity.MediaID = model.id;
         entity.StartTime = Convert.ToDateTime(model.startTime);
         entity.EndTime = Convert.ToDateTime(model.endTime);
         entity.Price = Convert.ToDecimal(model.price);
         entity.PeriodCode = model.periodCode;
         entity.PeriodCount = model.periodCount;
         if (string.IsNullOrEmpty(model.Name) && model.schemeId != 0)
         {
             entity.SchemeID = model.schemeId;
             if (SchemeItemService.GetALL().Any(x => x.MediaID == model.id && x.SchemeID == model.schemeId))
             {
                 result.AddServiceError("该方案已经包含了此媒体");
                 result.Message = "该方案已经包含了此媒体!";
             }
         }
         else
         {
             Scheme scheme = new Scheme()
             {
                 AddTime = DateTime.Now,
                 Name = model.Name,
                 Description = model.Description,
                 LastTime = DateTime.Now,
                 MemberID = CookieHelper.MemberID
             };
             SchemeService.Create(scheme);
             entity.SchemeID = scheme.ID;
         }
         if (result.Success)
         {
             SchemeItemService.Create(entity);
             result.Message = "加入方案成功!";
         }
     }
     catch (Exception ex)
     {
         result.Message = "加入方案失败!";
         result.AddServiceError(Utilities.GetInnerMostException(ex));
         LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "加入方案失败!", ex);
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }