public IHttpActionResult GetMailBoxFolderPermission([FromUri] string Name) { Runspace remoteRunspace = null; try { aOpenRunSpace.Open(GetUserData().AccountName, GetUserData().Password, ref remoteRunspace); var results = aMailBoxFolderPermissionHelpers.PSmailBoxFolderPermission(GetUserData().AccountName + ":\\" + Name, ref remoteRunspace); var RootFolderPermissionResults = aMailBoxFolderPermissionHelpers.RootFolderPermissionResults(results.Invoke()); var ErrorMsgs = aCommomHelpers.ReturnPowerShellInvokeErrors(results.Streams.Error); if (ErrorMsgs != null) { return(Content(HttpStatusCode.BadRequest, ErrorMsgs)); } return(Ok(RootFolderPermissionResults)); } catch (Exception e) { if (e.InnerException != null) { return(BadRequest(e.InnerException.Message)); } else { return(BadRequest(e.Message)); } } finally { remoteRunspace.Close(); remoteRunspace.Dispose(); } }
public IHttpActionResult Post([FromBody] AccountModel loginData) //UserLoginInfo { Runspace remoteRunspace = null; try { aOpenRunSpace.Open(loginData.AccountName, loginData.Password, ref remoteRunspace); var results = aAccountHelpers.UserData(loginData.AccountName, ref remoteRunspace); results.Invoke(); var ErrorMsgs = aCommomHelpers.ReturnPowerShellInvokeErrors(results.Streams.Error); if (ErrorMsgs != null) { return(Content(HttpStatusCode.BadRequest, ErrorMsgs)); } var secret = ConfigurationManager.AppSettings["JWTKey"].ToString(); var payload = new { loginData = loginData }; var Token = Jose.JWT.Encode(payload, Encoding.UTF8.GetBytes(secret), JwsAlgorithm.HS256); return(Ok(Token)); } catch (Exception e) { if (e.InnerException != null) { return(BadRequest(e.InnerException.Message)); } else { return(BadRequest(e.Message)); } } finally { remoteRunspace.Close(); } }