public ActionResult AddEnterpriseRole(EnterpriseRoleDto model) { var result = new StandardJsonResult <string>(); result.Try(() => { if (!ModelState.IsValid) { throw new KnownException(ModelState.GetFirstError()); } var service = Ioc.GetService <IEnterpriseRoleManagementService>(); string i = service.AddEnterpriseRole(model); result.Value = i;//赋值 }); return(result); }
public ActionResult GetEnterpriseRoleByRoleID(int RoleID) { var result = new StandardJsonResult <EnterpriseRoleDto>(); result.Try(() => { if (!ModelState.IsValid) { throw new KnownException(ModelState.GetFirstError()); } var service = Ioc.GetService <IEnterpriseRoleManagementService>(); EnterpriseRoleDto m = service.GetEnterpriseRoleByRoleID(RoleID); result.Value = m != null ? m : new EnterpriseRoleDto(); }); if (result.Success == false) { result.Value = new EnterpriseRoleDto(); } return(Json(result.Value, JsonRequestBehavior.AllowGet)); }