コード例 #1
0
        /// <summary>
        /// Function transmit the Form 941 Return to Efile
        /// </summary>
        /// <param name="submissionId">SubmissionId passed to transmit the 941 return</param>
        /// <returns>TransmitForm941SCHRResponse</returns>
        public ActionResult _TransmitReturn(Guid submissionId)
        {
            var transmitForm941SchR             = new TransmitForm();
            var transmitForm941SchRResponse     = new TransmitForm941SchRResponse();
            var transmitForm941SchRResponseJSON = string.Empty;

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

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

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

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

                        //Get Response
                        var _response = client.PostAsJsonAsync(requestUri, transmitForm941SchR).Result;
                        if (_response != null && _response.IsSuccessStatusCode)
                        {
                            //Read Response
                            var createResponse = _response.Content.ReadAsAsync <TransmitForm941SchRResponse>().Result;
                            if (createResponse != null)
                            {
                                transmitForm941SchRResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                                transmitForm941SchRResponse     = new JavaScriptSerializer().Deserialize <TransmitForm941SchRResponse>(transmitForm941SchRResponseJSON);
                                if (transmitForm941SchRResponse.SubmissionId != null && transmitForm941SchRResponse.SubmissionId != Guid.Empty && transmitForm941SchRResponse.StatusCode == (int)StatusCode.Success)
                                {
                                    //Updating Filing Status (Transmitted) for a specific SubmissionId in Session
                                    APISession.UpdateForm941SCHRReturnFilingStatus(transmitForm941SchRResponse.SubmissionId);
                                }
                            }
                        }
                        else
                        {
                            var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                            transmitForm941SchRResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                            transmitForm941SchRResponse     = new JavaScriptSerializer().Deserialize <TransmitForm941SchRResponse>(transmitForm941SchRResponseJSON);
                        }
                    }
                }
            }
            return(PartialView(transmitForm941SchRResponse));
        }
コード例 #2
0
        /// <summary>
        /// Function delete the Form 941SCHR Return to Efile
        /// </summary>
        /// <param name="submissionId">SubmissionId passed to delete the 941SCHR 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.GetForm941SCHRRecordIdsBySubmissionId(submissionId);
                deleteReturnRequest.RecordIds = recordIdsFromSession != null ? recordIdsFromSession.RecordIds : null;
                if (deleteReturnRequest.RecordIds != null && deleteReturnRequest.RecordIds.Count > 0)
                {
                    using (var client = new PublicAPIClient())
                    {
                        //API URL to Delete Form 941SCHR Return
                        string requestUri = "Form941SCHR/Delete";

                        //Delete
                        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.DeleteForm941SCHRAPIResponse(submissionId);
                                }
                            }
                        }
                        else
                        {
                            var createResponse = _response.Content.ReadAsAsync <Object>().Result;
                            deleteReturnResponseJSON = JsonConvert.SerializeObject(createResponse, Formatting.Indented);
                            deleteReturnResponse     = new JavaScriptSerializer().Deserialize <DeleteReturnResponse>(deleteReturnResponseJSON);
                        }
                    }
                }
            }
            return(PartialView(deleteReturnResponse));
        }