Пример #1
0
        public dynamic Post([FromBody] GetOutstandingInvoicesDto getOutstandingInvoicesDto, [FromUri] GetOutstandingInvoiceParameter parameter)
        {
            XmlToModelConverter xmlToModelConverter = new XmlToModelConverter();

            xmlRequest = this.OutstandingInvoiceService.CreateRequestXml(getOutstandingInvoicesDto, parameter);
            var response = this.OutstandingInvoiceService.PostXml(parameter, xmlRequest);

            if (response.IsSuccessStatusCode)
            {
                if (parameter.TransactionName.Equals("ARSummary"))
                {
                    ARSummary openinvoices = new ARSummary();
                    openinvoices = xmlToModelConverter.Deserialize <ARSummary>(response.Content.ReadAsStringAsync().Result);
                    return(openinvoices);
                }
                else if (parameter.TransactionName.Equals("AROpenInvoices"))
                {
                    AROpenInvoicesResult openinvoicesResult = new AROpenInvoicesResult();
                    openinvoicesResult.AROpenInvoices = xmlToModelConverter.Deserialize <AROpenInvoices>(response.Content.ReadAsStringAsync().Result);
                    openinvoicesResult.Pagination     = new PagingModel();
                    IQueryable <Invoice> invoiceQuery = openinvoicesResult.AROpenInvoices.Invoice.AsQueryable();

                    this.OutstandingInvoiceService.GetShiptos(invoiceQuery, getOutstandingInvoicesDto.CustomerNumber);
                    invoiceQuery = string.IsNullOrWhiteSpace(parameter.Sort) ? invoiceQuery.OrderBy <Invoice>("InvoiceDate") : invoiceQuery.OrderBy <Invoice>(parameter.Sort);

                    var pagedResult = this.OutstandingInvoiceService.ApplyPaging <Invoice>((PagingParameterBase)parameter, (PagingResultBase)openinvoicesResult.Pagination, invoiceQuery).ToList();

                    // Frontend Model
                    AROpenInvoicesResult openinvoices = new AROpenInvoicesResult();
                    openinvoices.AROpenInvoices            = new AROpenInvoices();
                    openinvoices.AROpenInvoices            = openinvoicesResult.AROpenInvoices;
                    openinvoices.PagedOpenInvoices         = new AROpenInvoices();
                    openinvoices.PagedOpenInvoices.Invoice = pagedResult.ToList <Invoice>();
                    openinvoices.Pagination = new PagingModel(openinvoicesResult.Pagination.Page, openinvoicesResult.Pagination.PageSize, openinvoicesResult.Pagination.DefaultPageSize, openinvoicesResult.Pagination.TotalCount);

                    if (openinvoicesResult.Pagination.Page > 1)
                    {
                        openinvoices.Pagination.PrevPageUri = this.OutstandingInvoiceService.GetLink(openinvoicesResult.Pagination, this.Request, openinvoicesResult.Pagination.Page - 1);
                    }
                    if (openinvoicesResult.Pagination.Page < openinvoicesResult.Pagination.TotalPages)
                    {
                        openinvoices.Pagination.NextPageUri = this.OutstandingInvoiceService.GetLink(openinvoicesResult.Pagination, this.Request, openinvoicesResult.Pagination.Page + 1);
                    }

                    return(openinvoices);
                }
                else
                {
                    ARInvoiceDetail openinvoices = new ARInvoiceDetail();
                    openinvoices = xmlToModelConverter.Deserialize <ARInvoiceDetail>(response.Content.ReadAsStringAsync().Result);
                    return(openinvoices);
                }
            }

            return(response);
        }
        public string CreateRequestXml(GetOutstandingInvoicesDto getOutstandingInvoicesDto, GetOutstandingInvoiceParameter parameter)
        {
            if (parameter.TransactionName.Equals("AROpenInvoices"))
            {
                xmlRequest = "<request name=" + '"' + parameter.TransactionName + '"' + "> <CompanyNumber>" + customSettings.CompanyNameIdentifier + "</CompanyNumber> <CustomerNumber>" + getOutstandingInvoicesDto.CustomerNumber + "</CustomerNumber> <InvoiceNumberInq>" + getOutstandingInvoicesDto.InvoiceNumberInq + "</InvoiceNumberInq> <ToInvoiceNumber>" + getOutstandingInvoicesDto.ToInvoiceNumber + "</ToInvoiceNumber> <MaxInvoices>" + customSettings.InforMaxInvoices + "</MaxInvoices> <FromInvDate>" + getOutstandingInvoicesDto.FromInvDate + "</FromInvDate> <ToInvDate>" + getOutstandingInvoicesDto.ToInvDate + "</ToInvDate> <FromAgeDate>" + getOutstandingInvoicesDto.FromAgeDate + "</FromAgeDate> <ToAgeDate>" + getOutstandingInvoicesDto.ToAgeDate + "</ToAgeDate> <FromInvAmount>" + getOutstandingInvoicesDto.FromInvAmount + "</FromInvAmount> <ToInvAmount>" + getOutstandingInvoicesDto.ToInvAmount + "</ToInvAmount> </request> ";
            }
            else if (parameter.TransactionName.Equals("ARInvoiceDetail"))
            {
                xmlRequest = "<request name=" + '"' + parameter.TransactionName + '"' + "> <CompanyNumber>" + customSettings.CompanyNameIdentifier + "</CompanyNumber> <CustomerNumber>" + getOutstandingInvoicesDto.CustomerNumber + "</CustomerNumber> <InvoiceType>" + getOutstandingInvoicesDto.InvoiceType + "</InvoiceType> <InvoiceNumber>" + getOutstandingInvoicesDto.InvoiceNumberInq + "</InvoiceNumber> <Flag>" + getOutstandingInvoicesDto.Flag + "</Flag> </request>";
            }
            else
            {
                xmlRequest = "<request name=" + '"' + parameter.TransactionName + '"' + "> <CompanyNumber>" + customSettings.CompanyNameIdentifier + "</CompanyNumber> <CustomerNumber>" + getOutstandingInvoicesDto.CustomerNumber + "</CustomerNumber> </request>";
            }

            return(xmlRequest);
        }