/// <summary> /// Function returns the Efile status of Form 941 /// </summary> /// <param name="submissionId">SubmissionId is passed to get the efile status</param> /// <returns>Form941StatusResponse</returns> public ActionResult _GetEfileStatusResponse(Guid submissionId, Guid RecordId) { Form941StatusResponse efileStatusResponse = new Form941StatusResponse(); if (submissionId != null && submissionId != Guid.Empty) { var efileRequest = new EfileStatusGetRequest { SubmissionId = submissionId }; var GetEfileStatusForm941ResponseJSON = string.Empty; // Request JSON var requestJson = JsonConvert.SerializeObject(efileRequest, Formatting.Indented); if (submissionId != null && submissionId != Guid.Empty) { //Get URLs from App.Config string apiUrl = Utility.GetAppSettings(Constants.PublicAPIUrlWithJWT); //Get Access token from GetAccessToken Class GetAccessToken AccessToken = new GetAccessToken(HttpContext); //Get Access token from OAuth API response var GeneratedAccessToken = AccessToken.GetGeneratedAccessToken(); //Access token is valid for one hour. After that call OAuth API again & get new Access token. if (!string.IsNullOrWhiteSpace(GeneratedAccessToken)) { using (var apiClient = new HttpClient()) { //GET var requestUri = "Form941/Status?SubmissionId=" + submissionId; apiClient.BaseAddress = new Uri(apiUrl); //Construct HTTP headers //If Access token got expired, call OAuth API again & get new Access token. OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, GeneratedAccessToken); //Read Response var _response = apiClient.GetAsync(requestUri).Result; if (_response != null && _response.IsSuccessStatusCode) { var createResponse = _response.Content.ReadAsAsync <Form941StatusResponse>().Result; if (createResponse != null) { GetEfileStatusForm941ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); efileStatusResponse = new JavaScriptSerializer().Deserialize <Form941StatusResponse>(GetEfileStatusForm941ResponseJSON); } } else { var createResponse = _response.Content.ReadAsAsync <Object>().Result; GetEfileStatusForm941ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); efileStatusResponse = new JavaScriptSerializer().Deserialize <Form941StatusResponse>(GetEfileStatusForm941ResponseJSON); } } } } } return(PartialView(efileStatusResponse)); }
/// <summary> /// Function get the single Business return using BusinessId /// </summary> /// <param name="BusinessId">BusinessId passed to get the single Business return</param> /// <returns>BusinessGetReturnResponse</returns> public ActionResult GetBusinessByBusinessId(Guid BusinessId, string EinOrSSN) { var BusinessGetReturnResponse = new BusinessGetResponse(); var BusinessGetReturnResponseJSON = string.Empty; if (BusinessId != null && BusinessId != Guid.Empty) { //Get URLs from App.Config string ApiUrl = Utility.GetAppSettings(Constants.PublicAPIUrlWithJWT); //Get Access token from GetAccessToken Class GetAccessToken AccessToken = new GetAccessToken(HttpContext); //Get Access token from OAuth API response var GeneratedAccessToken = AccessToken.GetGeneratedAccessToken(); if (!string.IsNullOrWhiteSpace(GeneratedAccessToken)) { using (var apiClient = new HttpClient()) { //API URL to Get Business Return using BusinessId and EIN string requestUri = "Business/Get?BusinessId=" + BusinessId + "&EIN=" + EinOrSSN; apiClient.BaseAddress = new Uri(ApiUrl); //Construct HTTP headers OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, GeneratedAccessToken); //Get Response var _response = apiClient.GetAsync(requestUri).Result; if (_response != null && _response.IsSuccessStatusCode) { //Read Response var createResponse = _response.Content.ReadAsAsync <BusinessGetResponse>().Result; if (createResponse != null) { BusinessGetReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); BusinessGetReturnResponse = new JavaScriptSerializer().Deserialize <BusinessGetResponse>(BusinessGetReturnResponseJSON); if (BusinessGetReturnResponse != null && BusinessGetReturnResponse.StatusCode == (int)StatusCodeList.Success) { ViewData["BusinessGetResponseJSON"] = BusinessGetReturnResponseJSON; return(PartialView("_GetSIngleBusiness")); } } } else { var createResponse = _response.Content.ReadAsAsync <Object>().Result; BusinessGetReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); BusinessGetReturnResponse = new JavaScriptSerializer().Deserialize <BusinessGetResponse>(BusinessGetReturnResponseJSON); } } } } return(PartialView("_GetSIngleBusiness", BusinessGetReturnResponse)); }
/// <summary> /// Function get the Form 941 Return to Efile /// </summary> /// <param name="submissionId">SubmissionId passed to get the 941 return</param> /// <returns>Form941GetReturnResponse</returns> public ActionResult GetForm941(Guid submissionId) { var getReturnResponse = new Form941GetReturnResponse(); var getReturnResponseJSON = string.Empty; if (submissionId != null && submissionId != Guid.Empty) { //Get URLs from App.Config string ApiUrl = Utility.GetAppSettings(Constants.PublicAPIUrlWithJWT); //Get Access token from GetAccessToken Class GetAccessToken AccessToken = new GetAccessToken(HttpContext); //Get Access token from OAuth API response var GeneratedAccessToken = AccessToken.GetGeneratedAccessToken(); if (!string.IsNullOrWhiteSpace(GeneratedAccessToken)) { using (var apiClient = new HttpClient()) { //API URL to Get Form 941 Return string requestUri = "Form941/Get?submissionId=" + submissionId; apiClient.BaseAddress = new Uri(ApiUrl); //Construct HTTP headers OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, GeneratedAccessToken); //Get Response var _response = apiClient.GetAsync(requestUri).Result; if (_response != null && _response.IsSuccessStatusCode) { //Read Response var createResponse = _response.Content.ReadAsAsync <Form941GetReturnResponse>().Result; if (createResponse != null) { getReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); getReturnResponse = new JavaScriptSerializer().Deserialize <Form941GetReturnResponse>(getReturnResponseJSON); if (getReturnResponse != null && getReturnResponse.StatusCode == (int)StatusCodeList.Success) { ViewData["GetResponseJSON"] = getReturnResponseJSON; return(PartialView()); } } } else { var createResponse = _response.Content.ReadAsAsync <Object>().Result; getReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); getReturnResponse = new JavaScriptSerializer().Deserialize <Form941GetReturnResponse>(getReturnResponseJSON); } } } } return(PartialView(getReturnResponse)); }
/// <summary> /// Function delete the Form 941 Return to Efile /// </summary> /// <param name="submissionId">SubmissionId passed to delete the 941 return</param> /// <returns>DeleteReturnResponse</returns> public ActionResult Delete(Guid submissionId) { var deleteReturnRequest = new DeleteReturnRequest(); var deleteReturnResponse = new DeleteReturnResponse(); var deleteReturnResponseJSON = string.Empty; if (submissionId != null && submissionId != Guid.Empty) { deleteReturnRequest.SubmissionId = submissionId; if (deleteReturnRequest.SubmissionId != null) { //Get URLs from App.Config string ApiUrl = Utility.GetAppSettings(Constants.PublicAPIUrlWithJWT); GetAccessToken AccessToken = new GetAccessToken(HttpContext); var GeneratedAccessToken = AccessToken.GetGeneratedAccessToken(); if (!string.IsNullOrWhiteSpace(GeneratedAccessToken)) { using (var apiClient = new HttpClient()) { //API URL to Transmit Form 941 Return string requestUri = "Form941/Delete?submissionId=" + submissionId; apiClient.BaseAddress = new Uri(ApiUrl); //Construct HTTP headers //If Access token got expired, call OAuth API again & get new Access token. OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, GeneratedAccessToken); //Get Response var _response = apiClient.DeleteAsync(requestUri).Result; if (_response != null && _response.IsSuccessStatusCode) { //Read Response var createResponse = _response.Content.ReadAsAsync <DeleteReturnResponse>().Result; if (createResponse != null) { deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); deleteReturnResponse = new JavaScriptSerializer().Deserialize <DeleteReturnResponse>(deleteReturnResponseJSON); } } else { var createResponse = _response.Content.ReadAsAsync <Object>().Result; deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); deleteReturnResponse = new JavaScriptSerializer().Deserialize <DeleteReturnResponse>(deleteReturnResponseJSON); } } } } } return(PartialView(deleteReturnResponse)); }
/// <summary> /// Function delete the Business return using BusinessId /// </summary> /// <param name="BusinessId">BusinessId passed to delete the Business return</param> /// <returns>DeleteReturnResponse</returns> public ActionResult Delete(Guid BusinessId) { var BusinessDeleteReturnRequest = new BusinessDeleteRequest(); var BusinessDeleteReturnResponse = new BusinessDeleteResponse(); var deleteReturnResponseJSON = string.Empty; if (BusinessId != null && BusinessId != Guid.Empty) { if (BusinessId != null) { //Get URLs from App.Config string ApiUrl = Utility.GetAppSettings(Constants.PublicAPIUrlWithJWT); GetAccessToken AccessToken = new GetAccessToken(HttpContext); var GeneratedAccessToken = AccessToken.GetGeneratedAccessToken(); if (!string.IsNullOrWhiteSpace(GeneratedAccessToken)) { using (var apiClient = new HttpClient()) { //API URL to Delete Business Return using BusinessId string requestUri = "Business/Delete?BusinessId=" + BusinessId; apiClient.BaseAddress = new Uri(ApiUrl); //Construct HTTP headers OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, GeneratedAccessToken); //Get Response var _response = apiClient.DeleteAsync(requestUri).Result; if (_response != null && _response.IsSuccessStatusCode) { //Read Response var createResponse = _response.Content.ReadAsAsync <BusinessDeleteResponse>().Result; if (createResponse != null) { deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); BusinessDeleteReturnResponse = new JavaScriptSerializer().Deserialize <BusinessDeleteResponse>(deleteReturnResponseJSON); } } else { var createResponse = _response.Content.ReadAsAsync <Object>().Result; deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); BusinessDeleteReturnResponse = new JavaScriptSerializer().Deserialize <BusinessDeleteResponse>(deleteReturnResponseJSON); } } } } } return(PartialView("_BusinessDeleteStatus", BusinessDeleteReturnResponse)); }
public ActionResult CreateBusiness(BusinessCreateRequest FormBusiness) { var responseJson = string.Empty; var BusinessResponse = new BusinessCreateReturnResponse(); string ApiUrl = Utility.GetAppSettings(Constants.PublicAPIUrlWithJWT); // Generate JSON for Business var requestJson = JsonConvert.SerializeObject(FormBusiness, Formatting.Indented); //Get Access token from OAuth API response GetAccessToken AccessToken = new GetAccessToken(HttpContext); string GeneratedAccessToken = AccessToken.GetGeneratedAccessToken(); if (!string.IsNullOrWhiteSpace(GeneratedAccessToken)) { using (var apiClient = new HttpClient()) { //API URL to Business Create string requestUri = "Business/Create"; apiClient.BaseAddress = new Uri(ApiUrl); //Construct HTTP headers in Generated Token. OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, GeneratedAccessToken); //Post Response var apiResponse = apiClient.PostAsJsonAsync(requestUri, FormBusiness).Result; if (apiResponse != null && apiResponse.IsSuccessStatusCode) { //Read Response var createResponse = apiResponse.Content.ReadAsAsync <BusinessCreateReturnResponse>().Result; if (createResponse != null) { responseJson = JsonConvert.SerializeObject(createResponse, Formatting.Indented); //Deserializing JSON (Success Response) to BusinessCreateReturnResponse object BusinessResponse = new JavaScriptSerializer().Deserialize <BusinessCreateReturnResponse>(responseJson); } } else { var createResponse = apiResponse.Content.ReadAsAsync <Object>().Result; responseJson = JsonConvert.SerializeObject(createResponse, Formatting.Indented); //Deserializing JSON (Error Response) to BusinessCreateReturnResponse object BusinessResponse = new JavaScriptSerializer().Deserialize <BusinessCreateReturnResponse>(responseJson); } } } return(PartialView("_BusinessReturnResponse", BusinessResponse)); }
/// <summary> /// Function get the Business Return /// </summary> /// <returns>BusinessReturnList</returns> public ActionResult GetBusinessList() { var ListReturnRepsone = new BusinessListResponse(); var Business = new List <Business>(); var getReturnResponseJSON = string.Empty; DateTime aDate = DateTime.Now; //Get URLs from App.Config string ApiUrl = Utility.GetAppSettings(Constants.PublicAPIUrlWithJWT); //Get Access token from GetAccessToken Class GetAccessToken AccessToken = new GetAccessToken(HttpContext); //Get Access token from OAuth API response var GeneratedAccessToken = AccessToken.GetGeneratedAccessToken(); if (!string.IsNullOrWhiteSpace(GeneratedAccessToken)) { using (var apiClient = new HttpClient()) { //API URL to Get Business List Return string requestUri = "Business/List?Page=0&PageSize=10"; apiClient.BaseAddress = new Uri(ApiUrl); //Construct HTTP headers OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, GeneratedAccessToken); //Get Response var _response = apiClient.GetAsync(requestUri).Result; if (_response != null && _response.IsSuccessStatusCode) { //Read Response var createResponse = _response.Content.ReadAsAsync <BusinessListResponse>().Result; if (createResponse != null) { getReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); ListReturnRepsone = new JavaScriptSerializer().Deserialize <BusinessListResponse>(getReturnResponseJSON); Business = ListReturnRepsone.Businesses; } } else { var createResponse = _response.Content.ReadAsAsync <Object>().Result; getReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); ListReturnRepsone = new JavaScriptSerializer().Deserialize <BusinessListResponse>(getReturnResponseJSON); } } } return(PartialView("_GetBusinessList", Business)); }
/// <summary> /// Function transmit the Form 941 Return to Efile /// </summary> /// <param name="submissionId">SubmissionId passed to transmit the 941 return</param> /// <returns>TransmitFormW2Response</returns> public ActionResult _TransmitReturn(Guid submissionId) { TransmitForm transmitForm941 = new TransmitForm(); var transmitForm941Response = new TransmitForm941Response(); var transmitForm941ResponseJSON = string.Empty; if (submissionId != null && submissionId != Guid.Empty) { transmitForm941.SubmissionId = submissionId; // Generate JSON for TransmitForm 941 var requestJson = JsonConvert.SerializeObject(transmitForm941, Formatting.Indented); if (transmitForm941 != null) { //Get URLs from App.Config string ApiUrl = Utility.GetAppSettings(Constants.PublicAPIUrlWithJWT); //Get Access token from GetAccessToken Class GetAccessToken AccessToken = new GetAccessToken(HttpContext); var GeneratedAccessToken = AccessToken.GetGeneratedAccessToken(); if (!string.IsNullOrWhiteSpace(GeneratedAccessToken)) { using (var apiClient = new HttpClient()) { //API URL to Transmit Form 941 Return string requestUri = "Form941/Transmit"; apiClient.BaseAddress = new Uri(ApiUrl); //Construct HTTP headers //If Access token got expired, call OAuth API again & get new Access token. OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, GeneratedAccessToken); //Get Response var _response = apiClient.PostAsJsonAsync(requestUri, transmitForm941).Result; if (_response != null && _response.IsSuccessStatusCode) { //Read Response var createResponse = _response.Content.ReadAsAsync <TransmitForm941Response>().Result; if (createResponse != null) { transmitForm941ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); transmitForm941Response = new JavaScriptSerializer().Deserialize <TransmitForm941Response>(transmitForm941ResponseJSON); if (transmitForm941Response.SubmissionId != null && transmitForm941Response.SubmissionId != Guid.Empty && transmitForm941Response.StatusCode == (int)StatusCodeList.Success) { //Updating Filing Status (Transmitted) for a specific SubmissionId in Session //bool Isupdated = APISession.UpdateForm941ReturnFilingStatus(transmitForm941Response.SubmissionId); //if (Isupdated) //{ // transmitForm941Response.IsReturnTransmitted = true; //} } } } else { var createResponse = _response.Content.ReadAsAsync <Object>().Result; transmitForm941ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); transmitForm941Response = new JavaScriptSerializer().Deserialize <TransmitForm941Response>(transmitForm941ResponseJSON); } } } } } return(PartialView(transmitForm941Response)); }
public ActionResult CreateForm941(Form941Data form941) { var responseJson = string.Empty; form941.Sequence = Constants.Sequence; form941.RecordId = null; form941.ReturnHeader.ReturnType = Constants.ReturnType; form941.ReturnHeader.Business.IsEIN = true; form941.ReturnHeader.Business.IsForeign = false; form941.ReturnData.Form941.IsPayrollTaxCredit = false; if (form941?.ReturnHeader?.ThirdPartyDesignee != null && (!string.IsNullOrEmpty(form941.ReturnHeader.ThirdPartyDesignee.Name) || !string.IsNullOrEmpty(form941.ReturnHeader.ThirdPartyDesignee.Phone) || !string.IsNullOrEmpty(form941.ReturnHeader.ThirdPartyDesignee.PIN))) { form941.ReturnHeader.IsThirdPartyDesignee = true; } if (form941?.ReturnHeader?.BusinessStatusDetails != null) { if (form941.ReturnHeader.BusinessStatusDetails.IsBusinessClosed == false) { form941.ReturnHeader.BusinessStatusDetails.BusinessClosedDetails = new BusinessClosedDetails(); } if (form941.ReturnHeader.BusinessStatusDetails.IsBusinessTransferred == false) { form941.ReturnHeader.BusinessStatusDetails.BusinessTransferredDetails = new BusinessTransferredDetails(); } } var form941Response = new Form941CreateReturnResponse(); var form941ReturnList = new Form941CreateReturnRequest { Form941Records = new List <Form941Data>() }; form941ReturnList.Form941Records.Add(form941); string ApiUrl = Utility.GetAppSettings(Constants.PublicAPIUrlWithJWT); // Generate JSON for Form 941 var requestJson = JsonConvert.SerializeObject(form941ReturnList, Formatting.Indented); //Get Access token from OAuth API response GetAccessToken AccessToken = new GetAccessToken(HttpContext); string GeneratedAccessToken = AccessToken.GetGeneratedAccessToken(); if (!string.IsNullOrWhiteSpace(GeneratedAccessToken)) { using (var apiClient = new HttpClient()) { //API URL to Create Form 941 Return string requestUri = "Form941/Create"; apiClient.BaseAddress = new Uri(ApiUrl); //Construct HTTP headers in Generated Token. OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, GeneratedAccessToken); //Post Response var apiResponse = apiClient.PostAsJsonAsync(requestUri, form941ReturnList).Result; if (apiResponse != null && apiResponse.IsSuccessStatusCode) { //Read Response var createResponse = apiResponse.Content.ReadAsAsync <Form941CreateReturnResponse>().Result; if (createResponse != null) { responseJson = JsonConvert.SerializeObject(createResponse, Formatting.Indented); //Deserializing JSON (Success Response) to Form941CreateReturnResponse object form941Response = new JavaScriptSerializer().Deserialize <Form941CreateReturnResponse>(responseJson); } } else { var createResponse = apiResponse.Content.ReadAsAsync <Object>().Result; responseJson = JsonConvert.SerializeObject(createResponse, Formatting.Indented); //Deserializing JSON (Error Response) to Form941CreateReturnResponse object form941Response = new JavaScriptSerializer().Deserialize <Form941CreateReturnResponse>(responseJson); } } } return(PartialView("APIResponseStatus", form941Response)); }