Пример #1
0
        public ActionResult Edit(int id)
        {
            ViewBag.MenuItem = "scheme-media";

            var scheme = SchemeService.Find(id);

            var model = new SchemeAddViewModel()
            {
                ID = scheme.ID,
                Name = scheme.Name,
                Description = scheme.Description
            };

            return View(model);
        }
Пример #2
0
 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
        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);
        }