public object SavePlanSet(PlanSet entity) { using (var db = new WeeklyEntities()) { var loginner = FormsAuth.GetUserData<LoginerBase>(); int execCount = 0; if (entity.Id == 0) { entity.CreateBy = loginner.Name; entity.CreateById = loginner.UserID; entity.CreateByDate = DateTime.Now; db.PlanSets.Add(entity); } else { var oldEntity = db.PlanSets.First(p => p.Id == entity.Id); oldEntity.PBegin = entity.PBegin; oldEntity.BeginDay = entity.BeginDay; oldEntity.PEnd = entity.PEnd; oldEntity.EndDay = entity.EndDay; oldEntity.Content = entity.Content; oldEntity.Place = entity.Place; oldEntity.Leads = entity.Leads; oldEntity.UndertakeDept = entity.UndertakeDept; oldEntity.ParticipationDept = entity.ParticipationDept; oldEntity.PState = entity.PState; } execCount = db.SaveChanges(); if (execCount > 0) return new { status = "success", message = "操作成功!" }; else return new { status = "error", message = "操作失败,请检查!" }; } }
public ActionResult SavePlanSet(PlanSet entity) { var message = new PlanSetService().SavePlanSet(entity); return Json(message, JsonRequestBehavior.DenyGet); }