public ActionResult SetPreviewPlan(EditPlanSM sm) { try { Plan plan = sm.ToPlan(); EvaluationContext context = plan.CreateEvaluationContext(); Session["Context"] = context; SetUpdateCount(sm.EditID); return(new JsonResult() { Data = new { success = true }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { Response.StatusCode = 500; return(new JsonResult() { Data = new { message = ex.Message.Replace("\r\n", "<br/>") }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public ActionResult SavePlan(EditPlanSM sm) { try { //UserLM user = Session["User"] as UserLM; var userid = Convert.ToInt32(HttpContext.Request.Cookies["userid"].Value); Plan plan = sm.ToPlan(); plan.Author = userid.ToString(); EvaluationContext context = plan.CreateEvaluationContext(); string id; if (!string.IsNullOrEmpty(sm.ID)) { id = sm.ID; Script.UpdatePlan(sm.ID, plan); } else { id = Script.AddPlan(plan).ID; sm.UserRole = 2; } return(new JsonResult() { Data = new { success = true, PlanID = id }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { //Response.StatusCode = 500; return(new JsonResult() { Data = new { message = ex.Message.Replace("\r\n", "<br/>") }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }