当前位置: 首页>>代码示例>>C#>>正文


C# DataClassesDataContext.AccountSalesService方法代码示例

本文整理汇总了C#中DataClassesDataContext.AccountSalesService方法的典型用法代码示例。如果您正苦于以下问题:C# DataClassesDataContext.AccountSalesService方法的具体用法?C# DataClassesDataContext.AccountSalesService怎么用?C# DataClassesDataContext.AccountSalesService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataClassesDataContext的用法示例。


在下文中一共展示了DataClassesDataContext.AccountSalesService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetInvoice

        public HttpResponseMessage GetInvoice(SearchFilter searchFilter)
        {
            List<InvoiceFrontEndViewModel> resultList = new List<InvoiceFrontEndViewModel>();
            using (DataClassesDataContext context = new DataClassesDataContext())
            {
                try
                {
                    var invoices = context.AccountSalesService(searchFilter.StartDate, searchFilter.EndDate);

                    foreach (var invoice in invoices)
                    {
                        string customerName = "";
                        try
                        {
                            customerName = getCustomerName(invoice.ContactName);
                        }
                        catch (CustomerDoesNotExistException e)
                        {
                            ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                            return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
                        }
                        InvoiceFrontEndViewModel invoiceViewModel = new InvoiceFrontEndViewModel()
                        {
                            InvoiceNumber = invoice.InvoiceNumber,

                            ContactName = getCustomerName(invoice.ContactName),
                            Email = invoice.EmailAddress,
                            Address1 = invoice.POAddressLine1,
                            Address2 = invoice.POAddressLine2,
                            Address3 = invoice.POAddressLine3,
                            City = invoice.POCity,
                            Region = invoice.PORegion,
                            Country = invoice.POCountry,
                            PostalCode = invoice.POPostalCode,
                            InvoiceDate = invoice.InvoiceDate.GetValueOrDefault().ToString("dd-MM-yy"),
                            DueDate = invoice.DueDate.GetValueOrDefault().ToString("dd-MM-yy"),
                            InventoryItemCode = invoice.InventoryItemCode.ToString(),
                            Description = invoice.Description,
                            Quantity = invoice.Quantity.ToString(),
                            UnitAmount = invoice.UnitAmount.ToString(),
                            Discount = invoice.Discount.ToString(),
                            AccountCode = invoice.AccountCode.ToString(),
                            TaxType = invoice.TaxType,
                            TrackingName = invoice.TrackingName1,
                            TrackingOption = invoice.TrackingOption1,
                            Currency = "NZD",
                            BrandingTheme = invoice.BrandingTheme
                        };

                        resultList.Add(invoiceViewModel);
                    }
                }
                catch (System.Data.SqlClient.SqlException)
                {
                    ModelStateDictionary dictionary = errorStringConvertor.Convert("To many invoices in daterange");
                    return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
                }

                return this.Request.CreateResponse(HttpStatusCode.OK, resultList);
            }
        }
开发者ID:markplaatsman,项目名称:XeroIntegration,代码行数:61,代码来源:InvoiceWebApiController.cs

示例2: PostInvoicesToXero

        public HttpResponseMessage PostInvoicesToXero(SearchFilter searchFilter)
        {
            using (DataClassesDataContext context = new DataClassesDataContext())
            {
                try
                {
                    var invoices = context.AccountSalesService(searchFilter.StartDate, searchFilter.EndDate);
                    foreach (var invoice in invoices)
                    {
                        InvoiceToInvoiceViewModelConverter invoiceConverter = new InvoiceToInvoiceViewModelConverter();
                        try
                        {
                            InvoiceViewModel invoiceViewModel = invoiceConverter.Convert(invoice);
                            invoicesToPostList.Add(invoiceViewModel);
                        }
                        catch (InvoiceValidationException e)
                        {
                            ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                            return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
                        }
                        catch (CustomerDoesNotExistException e)
                        {
                            ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                            return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
                        }
                    }
                }
                catch (System.Data.SqlClient.SqlException)
                {
                    ModelStateDictionary dictionary = errorStringConvertor.Convert("To many invoices in daterange");
                    return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);

                }
            }
            try
            {
                xeroLogic.ExportInvoices(invoicesToPostList);
            }
            catch (XeroApiLimitException e)
            {
                ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                return this.Request.CreateErrorResponse(HttpStatusCode.BadGateway, dictionary);
            }
            catch (XeroException e)
            {
                ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
            }
            catch (XeroApiValidationException e)
            {
                ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
            }
            catch (Exception)
            {
                ModelStateDictionary dictionary = errorStringConvertor.Convert("Something went wrong. Please check the data and try again.");
                return this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, dictionary);
            }

            return this.Request.CreateResponse(HttpStatusCode.OK);
        }
开发者ID:markplaatsman,项目名称:XeroIntegration,代码行数:61,代码来源:ExportInvoicesToXeroWebApiController.cs


注:本文中的DataClassesDataContext.AccountSalesService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。