예제 #1
0
        /// <summary>
        /// Function transmit the Form W-2 Return to Efile
        /// </summary>
        /// <param name="submissionId">SubmissionId passed to transmit the W-2 return</param>
        /// <returns>TransmitFormW2Response</returns>
        public ActionResult _TransmitReturn(Guid submissionId)
        {
            TransmitForm           transmitFormW2         = new TransmitForm();
            TransmitFormW2Response transmitFormW2Response = new TransmitFormW2Response();
            var transmitFormW2ResponseJSON = string.Empty;

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

                // Generate JSON for TransmitFormW2
                var requestJson = JsonConvert.SerializeObject(transmitFormW2, Formatting.Indented);

                if (transmitFormW2 != null)
                {
                    using (var client = new PublicAPIClient())
                    {
                        //API URL to Transmit Form W-2 Return
                        string requestUri = "FormW2/Transmit";

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

                        //Get Response
                        var _response = client.PostAsJsonAsync(requestUri, transmitFormW2).Result;
                        if (_response != null && _response.IsSuccessStatusCode)
                        {
                            //Read Response
                            var createResponse = _response.Content.ReadAsAsync <TransmitFormW2Response>().Result;
                            if (createResponse != null)
                            {
                                transmitFormW2ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                                transmitFormW2Response     = new JavaScriptSerializer().Deserialize <TransmitFormW2Response>(transmitFormW2ResponseJSON);
                                if (transmitFormW2Response.SubmissionId != null && transmitFormW2Response.SubmissionId != Guid.Empty && transmitFormW2Response.StatusCode == (int)StatusCode.Success)
                                {
                                    //Updating Filing Status (Transmitted) for a specific SubmissionId in Session
                                    APISession.UpdateFilingStatus(transmitFormW2Response.SubmissionId);
                                }
                            }
                        }
                        else
                        {
                            var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                            transmitFormW2ResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                            transmitFormW2Response     = new JavaScriptSerializer().Deserialize <TransmitFormW2Response>(transmitFormW2ResponseJSON);
                        }
                    }
                }
            }
            return(PartialView(transmitFormW2Response));
        }