예제 #1
0
        /// <summary>
        /// Function List the Form W2 Return to Efile
        /// </summary>
        public ActionResult _ListFormW2(Guid?id, string Ein, int Page, int PageSize, string ES, string FD, string TD)
        {
            var getReturnResponse     = new FormW2RecordsResponse();
            var getReturnResponseJSON = string.Empty;

            string requestURI = string.Empty;
            Guid   Bid        = id ?? Guid.Empty;

            if (string.IsNullOrWhiteSpace(ES))
            {
                ES = "null";
            }
            if (string.IsNullOrWhiteSpace(FD))
            {
                FD = "null";
            }
            if (string.IsNullOrWhiteSpace(TD))
            {
                TD = "null";
            }
            requestURI = "?BusinessId=" + Bid + "&EIN=" + Ein + "&Page=" + Page + "&PageSize=" + PageSize + "&EfileStatus=" + ES + "&FromDate=" + FD + "&ToDate=" + TD;
            using (var client = new PublicAPIClient())
            {
                //API URL to Get Form W2 Return
                string requestUri = "FormW2/List" + requestURI;

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

                //Get Response
                var _response = client.GetAsync(requestUri).Result;
                if (_response != null && _response.IsSuccessStatusCode)
                {
                    //Read Response
                    var getResponse = _response.Content.ReadAsAsync <FormW2RecordsResponse>().Result;
                    if (getResponse != null)
                    {
                        getReturnResponseJSON       = JsonConvert.SerializeObject(getResponse, Formatting.Indented);
                        getReturnResponse           = new JavaScriptSerializer().Deserialize <FormW2RecordsResponse>(getReturnResponseJSON);
                        ViewData["GetResponseJSON"] = getReturnResponseJSON;
                        return(PartialView());
                    }
                }
                else
                {
                    var getResponse = _response.Content.ReadAsAsync <Object>().Result;
                    getReturnResponseJSON       = JsonConvert.SerializeObject(getResponse, Formatting.Indented);
                    getReturnResponse           = new JavaScriptSerializer().Deserialize <FormW2RecordsResponse>(getReturnResponseJSON);
                    ViewData["GetResponseJSON"] = getReturnResponseJSON;
                    return(PartialView());
                }
            }
            return(PartialView(getReturnResponseJSON));
        }
예제 #2
0
        /// <summary>
        /// Function returns the Efile status of Form W-2
        /// </summary>
        /// <param name="submissionId">SubmissionId is passed to get the efile status</param>
        /// <returns>EfileStatusResponse</returns>
        public ActionResult _GetEfileStatusResponse(Guid submissionId)
        {
            EfileStatusResponse efileStatusResponse = new EfileStatusResponse();

            if (submissionId != null && submissionId != Guid.Empty)
            {
                var efileRequest = new EfileStatusGetRequest {
                    SubmissionId = submissionId
                };
                var recordIds       = APISession.GetRecordIdsBySubmissionId(submissionId);
                var recordIdsString = string.Empty;
                if (recordIds != null && recordIds.RecordIds != null && recordIds.RecordIds.Count > 0)
                {
                    efileRequest.RecordIds = recordIds.RecordIds;
                    recordIdsString        = string.Join(",", 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())
                    {
                        //GET
                        string requestUri = "FormW2/Status?SubmissionId=" + submissionId + "&RecordIds=" + recordIdsString;

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

                        //Read Response
                        var _response = client.GetAsync(requestUri).Result;
                        if (_response != null && _response.IsSuccessStatusCode)
                        {
                            var createResponse = _response.Content.ReadAsAsync <EfileStatusResponse>().Result;
                            if (createResponse != null)
                            {
                                transmitFormW2ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                                efileStatusResponse        = new JavaScriptSerializer().Deserialize <EfileStatusResponse>(transmitFormW2ResponseJSON);
                            }
                        }
                        else
                        {
                            var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                            transmitFormW2ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                            efileStatusResponse        = new JavaScriptSerializer().Deserialize <EfileStatusResponse>(transmitFormW2ResponseJSON);
                        }
                    }
                }
            }
            return(PartialView(efileStatusResponse));
        }
        /// <summary>
        /// Function get the Form 941SCHR Return to Efile
        /// </summary>
        /// <param name="submissionId">SubmissionId passed to get the 941SCHR return</param>
        /// <returns></returns>
        public ActionResult GetForm941SchR(Guid submissionId)
        {
            var getReturnResponse     = new Form941SchRGetReturnResponse();
            var getReturnResponseJSON = string.Empty;

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

                if (!string.IsNullOrEmpty(recordIds))
                {
                    using (var client = new PublicAPIClient())
                    {
                        //API URL to Get Form 941SCHR Return
                        string requestUri = "Form941SCHR/Get?SubmissionId=" + submissionId;

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

                        //Get Response
                        var _response = client.GetAsync(requestUri).Result;
                        if (_response != null && _response.IsSuccessStatusCode)
                        {
                            //Read Response
                            var createResponse = _response.Content.ReadAsAsync <Form941SchRGetReturnResponse>().Result;
                            if (createResponse != null)
                            {
                                getReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                                getReturnResponse     = new JavaScriptSerializer().Deserialize <Form941SchRGetReturnResponse>(getReturnResponseJSON);
                                if (getReturnResponse != null && getReturnResponse.StatusCode == (int)StatusCode.Success)
                                {
                                    ViewData["GetResponseJSON"] = getReturnResponseJSON;
                                    return(PartialView());
                                }
                            }
                        }
                        else
                        {
                            var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                            getReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                            getReturnResponse     = new JavaScriptSerializer().Deserialize <Form941SchRGetReturnResponse>(getReturnResponseJSON);
                        }
                    }
                }
            }
            return(PartialView(getReturnResponse));
        }
        /// <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)
            {
                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 Get Form 941 Return
                                        string requestUri = "Form941/Get?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, accessToken);

                                        //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)StatusCode.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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    using (var client = new PublicAPIClient())
                    {
                        //API URL to Get Form 941 Return
                        string requestUri = "Form941/Get?submissionId=" + submissionId;

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

                        //Get Response
                        var _response = client.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)StatusCode.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));
        }