コード例 #1
0
        /// <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)
        {
            var transmitForm941             = new TransmitForm();
            var transmitForm941Response     = new TransmitForm941Response();
            var transmitForm941ResponseJSON = string.Empty;

            if (submissionId != null && submissionId != Guid.Empty)
            {
                // Getting the RecordIds for SubmissionId
                transmitForm941 = APISession.GetForm941RecordIdsBySubmissionId(submissionId);

                // Generate JSON for TransmitForm 941
                var requestJson = JsonConvert.SerializeObject(transmitForm941, Formatting.Indented);

                if (transmitForm941 != null)
                {
                    using (var client = new PublicAPIClient())
                    {
                        //API URL to Transmit Form 941 Return
                        string requestUri = "Form941/Transmit";

                        //POST
                        APIGenerateAuthHeader.GenerateAuthHeader(client, requestUri, "POST");

                        //Get Response
                        var _response = client.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)StatusCode.Success)
                                {
                                    //Updating Filing Status (Transmitted) for a specific SubmissionId in Session
                                    APISession.UpdateForm941ReturnFilingStatus(transmitForm941Response.SubmissionId);
                                }
                            }
                        }
                        else
                        {
                            var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                            transmitForm941ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                            transmitForm941Response     = new JavaScriptSerializer().Deserialize <TransmitForm941Response>(transmitForm941ResponseJSON);
                        }
                    }
                }
            }
            return(PartialView(transmitForm941Response));
        }
コード例 #2
0
        /// <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)
        {
            var efileStatusResponse = new Form941SCHRStatusResponse();

            if (submissionId != null && submissionId != Guid.Empty)
            {
                var efileRequest = new EfileStatusGetRequest {
                    SubmissionId = submissionId
                };
                var recordIds = APISession.GetForm941RecordIdsBySubmissionId(submissionId);
                if (recordIds != null && recordIds.RecordIds != null && recordIds.RecordIds.Count > 0)
                {
                    efileRequest.RecordIds = recordIds.RecordIds;
                }
                var transmitFormW2ResponseJSON = string.Empty;

                // Request JSON
                var requestJson = JsonConvert.SerializeObject(efileRequest, Formatting.Indented);

                if (submissionId != null && submissionId != Guid.Empty)
                {
                    using (var client = new PublicAPIClient())
                    {
                        //POST
                        string requestUri = "Form941SCHR/Status";

                        //Get Response
                        APIGenerateAuthHeader.GenerateAuthHeader(client, requestUri, "POST");

                        //Read Response
                        var _response = client.PostAsJsonAsync(requestUri, efileRequest).Result;
                        if (_response != null && _response.IsSuccessStatusCode)
                        {
                            var createResponse = _response.Content.ReadAsAsync <Form941SCHRStatusResponse>().Result;
                            if (createResponse != null)
                            {
                                transmitFormW2ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                                efileStatusResponse        = new JavaScriptSerializer().Deserialize <Form941SCHRStatusResponse>(transmitFormW2ResponseJSON);
                            }
                        }
                        else
                        {
                            var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                            transmitFormW2ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                            efileStatusResponse        = new JavaScriptSerializer().Deserialize <Form941SCHRStatusResponse>(transmitFormW2ResponseJSON);
                        }
                    }
                }
            }
            return(PartialView(efileStatusResponse));
        }
コード例 #3
0
        /// <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;
                // Getting the RecordIds for SubmissionId
                var recordIdsFromSession = APISession.GetForm941RecordIdsBySubmissionId(submissionId);
                deleteReturnRequest.RecordIds = recordIdsFromSession != null ? recordIdsFromSession.RecordIds : null;
                if (deleteReturnRequest.RecordIds != null && deleteReturnRequest.RecordIds.Count > 0)
                {
                    using (var client = new PublicAPIClient())
                    {
                        //API URL to Transmit Form 941 Return
                        string requestUri = "Form941/Delete";

                        //POST
                        APIGenerateAuthHeader.GenerateAuthHeader(client, requestUri, "POST");

                        //Get Response
                        var _response = client.PostAsJsonAsync(requestUri, deleteReturnRequest).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);
                                if (deleteReturnResponse != null && deleteReturnResponse.StatusCode == (int)StatusCode.Success)
                                {
                                    //Remove Submission and RecordId from session
                                    APISession.DeleteForm941APIResponse(submissionId);
                                }
                            }
                        }
                        else
                        {
                            var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                            deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                            deleteReturnResponse     = new JavaScriptSerializer().Deserialize <DeleteReturnResponse>(deleteReturnResponseJSON);
                        }
                    }
                }
            }
            return(PartialView(deleteReturnResponse));
        }
コード例 #4
0
        /// <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;
                // Getting the RecordIds for SubmissionId
                var recordIdsFromSession = APISession.GetForm941RecordIdsBySubmissionId(submissionId);
                deleteReturnRequest.RecordIds = recordIdsFromSession != null ? recordIdsFromSession.RecordIds : null;
                if (deleteReturnRequest.RecordIds != null && deleteReturnRequest.RecordIds.Count > 0)
                {
                    string authType = Utility.GetAppSettings("AuthenticationType");
                    if (!string.IsNullOrWhiteSpace(authType) && authType.ToUpper() == "JWT")
                    {
                        //Get URLs from App.Config
                        string oAuthApiUrl = Utility.GetAppSettings("OAuthApiUrl");
                        string apiUrl      = Utility.GetAppSettings("PublicAPIUrlWithJWT");

                        //Call OAuth API
                        using (var oAuthClient = new HttpClient())
                        {
                            string oAuthRequestUri = Utility.GetAppSettings("OAuthApiMethodRoute");
                            oAuthClient.BaseAddress = new Uri(oAuthApiUrl);

                            //Generate JWS and get access token (JWT)
                            OAuthGenerator.GenerateJWSAndGetAccessToken(oAuthClient);

                            //Read OAuth API response
                            var response = oAuthClient.GetAsync(oAuthRequestUri).Result;
                            if (response != null && response.IsSuccessStatusCode)
                            {
                                var oauthApiResponse = response.Content.ReadAsAsync <AccessTokenResponse>().Result;
                                if (oauthApiResponse != null && oauthApiResponse.StatusCode == 200)
                                {
                                    //Get Access token from OAuth API response
                                    string accessToken = oauthApiResponse.AccessToken;
                                    //Access token is valid for one hour. After that call OAuth API again & get new Access token.

                                    if (!string.IsNullOrWhiteSpace(accessToken))
                                    {
                                        //Call TaxBandits API using the Access token
                                        //Access token is valid for one hour. After that call OAuth API again & get new Access token.
                                        using (var apiClient = new HttpClient())
                                        {
                                            //API URL to Transmit Form 941 Return
                                            string requestUri = "Form941/Delete";

                                            apiClient.BaseAddress = new Uri(apiUrl);
                                            //Construct HTTP headers
                                            //If Access token got expired, call OAuth API again & get new Access token.
                                            OAuthGenerator.ConstructHeadersWithAccessToken(apiClient, accessToken);

                                            //Get Response
                                            var _response = apiClient.PostAsJsonAsync(requestUri, deleteReturnRequest).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);
                                                    if (deleteReturnResponse != null && deleteReturnResponse.StatusCode == (int)StatusCode.Success)
                                                    {
                                                        //Remove Submission and RecordId from session
                                                        APISession.DeleteForm941APIResponse(submissionId);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                                                deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                                                deleteReturnResponse     = new JavaScriptSerializer().Deserialize <DeleteReturnResponse>(deleteReturnResponseJSON);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        using (var client = new PublicAPIClient())
                        {
                            //API URL to Transmit Form 941 Return
                            string requestUri = "Form941/Delete";

                            //POST
                            APIGenerateAuthHeader.GenerateAuthHeader(client, requestUri, "POST");

                            //Get Response
                            var _response = client.PostAsJsonAsync(requestUri, deleteReturnRequest).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);
                                    if (deleteReturnResponse != null && deleteReturnResponse.StatusCode == (int)StatusCode.Success)
                                    {
                                        //Remove Submission and RecordId from session
                                        APISession.DeleteForm941APIResponse(submissionId);
                                    }
                                }
                            }
                            else
                            {
                                var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                                deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                                deleteReturnResponse     = new JavaScriptSerializer().Deserialize <DeleteReturnResponse>(deleteReturnResponseJSON);
                            }
                        }
                    }
                }
            }
            return(PartialView(deleteReturnResponse));
        }