/// <summary> /// Function delete the Form W2 Return to Efile /// </summary> /// <param name="submissionId">SubmissionId passed to delete the W-2 return</param> /// <returns></returns> public ActionResult Delete(Guid submissionId) { var deleteReturnRequest = new DeleteReturnRequest(); var deleteReturnResponse = new FormW2DeleteReturnResponse(); var deleteReturnResponseJSON = string.Empty; var recordIdsString = string.Empty; if (submissionId != null && submissionId != Guid.Empty) { if (submissionId != null && submissionId != Guid.Empty) { deleteReturnRequest.SubmissionId = submissionId; // Getting the RecordIds for SubmissionId var recordIdsFromSession = APISession.GetRecordIdsBySubmissionId(submissionId); deleteReturnRequest.RecordIds = recordIdsFromSession != null ? recordIdsFromSession.RecordIds : null; if (deleteReturnRequest.RecordIds != null && deleteReturnRequest.RecordIds.Count > 0) { recordIdsString = string.Join(",", deleteReturnRequest.RecordIds); using (var client = new PublicAPIClient()) { //API URL to Delete Form W-2 Return string requestUri = "FormW2/Delete?SubmissionId=" + submissionId + "&RecordIds=" + recordIdsString; //Delete APIGenerateAuthHeader.GenerateAuthHeader(client, requestUri, "DELETE"); //Get Response var _response = client.DeleteAsync(requestUri).Result; if (_response != null && _response.IsSuccessStatusCode) { //Read Response var createResponse = _response.Content.ReadAsAsync <FormW2DeleteReturnResponse>().Result; if (createResponse != null) { deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); deleteReturnResponse = new JavaScriptSerializer().Deserialize <FormW2DeleteReturnResponse>(deleteReturnResponseJSON); if (deleteReturnResponse != null && deleteReturnResponse.StatusCode == (int)StatusCode.Success) { //Todo Remove Submission and RecordId from session APISession.DeleteFormW2APIResponse(submissionId); } } } else { var createResponse = _response.Content.ReadAsAsync <Object>().Result; deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented); deleteReturnResponse = new JavaScriptSerializer().Deserialize <FormW2DeleteReturnResponse>(deleteReturnResponseJSON); } } } } } return(PartialView(deleteReturnResponse)); }
/// <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 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)); }