Beispiel #1
0
        public ActionResult Create(PunishViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Score == 0)
                    {
                        var rule = RuleCateService.Find(model.RuleID);
                        model.Score = rule.OrderIndex;
                    }
                    PunishService.Create(model);
                    result.Message = "添加行政奖惩成功!";
                    LogHelper.WriteLog("添加行政奖惩告成功");
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加行政奖惩错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }

            ViewBag.Data_RuleID = Utilities.GetSelectListData(
                RuleCateService.GetALL().Where(x => x.PID.Equals(null))
                , x => x.ID, x => x.CateName, true);

            return View(model);
        }
Beispiel #2
0
        public ActionResult Edit(PunishEditViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    var entity = new PunishViewModel()
                    {
                        ID = model.ID,
                        Description = model.Description,
                        MemberID = model.MemberID,
                        RuleID = model.RuleID,
                        Score = model.Score
                    };
                    PunishService.Update(entity);
                    result.Message = "编辑行政奖惩成功!";
                    LogHelper.WriteLog("编辑行政奖惩成功");
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("编辑行政奖惩错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }
            ViewBag.Data_RuleID = Utilities.GetSelectListData(
            RuleCateService.GetALL().Where(x => x.PID.Equals(null))
            , x => x.ID, x => x.CateName, model.RuleID, true);
            return View(model);
        }