public object saveRole(Role 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.Roles.Add(entity); } else { var oldEntity = db.Roles.First(p => p.Id == entity.Id); oldEntity.Name = entity.Name; oldEntity.OrgTypeId = entity.OrgTypeId; } execCount = db.SaveChanges(); if (execCount > 0) return new { status = "success", message = "操作成功!" }; else return new { status = "error", message = "操作失败,请检查!" }; } }
public ActionResult saveRole(Role entity) { var message = new RoleService().saveRole(entity); return Json(message, JsonRequestBehavior.DenyGet); }