本文整理汇总了C#中DataClassesDataContext.XEROPurchases方法的典型用法代码示例。如果您正苦于以下问题:C# DataClassesDataContext.XEROPurchases方法的具体用法?C# DataClassesDataContext.XEROPurchases怎么用?C# DataClassesDataContext.XEROPurchases使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataClassesDataContext
的用法示例。
在下文中一共展示了DataClassesDataContext.XEROPurchases方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostPurchasesToXero
public HttpResponseMessage PostPurchasesToXero(SearchFilter searchFilter)
{
using (DataClassesDataContext context = new DataClassesDataContext())
{
try
{
var purchases = context.XEROPurchases(searchFilter.StartDate, searchFilter.EndDate);
foreach (var purchase in purchases)
{
PurchaseToInvoiceViewModelConverter purchaseConverter = new PurchaseToInvoiceViewModelConverter();
try
{
InvoiceViewModel invoiceViewModel = purchaseConverter.Convert(purchase);
purchasesToPostList.Add(invoiceViewModel);
}
catch (InvoiceValidationException e)
{
ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message);
}
catch (SupplierDoesNotExistException e)
{
ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message);
}
}
}
catch (System.Data.SqlClient.SqlException)
{
ModelStateDictionary dictionary = errorStringConvertor.Convert("To many Purchases in daterange");
return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
}
}
try
{
xeroLogic.ExportInvoices(purchasesToPostList);
}
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);
}
示例2: GetPurchases
public HttpResponseMessage GetPurchases(SearchFilter searchFilter)
{
List<PurchaseViewModel> resultList = new List<PurchaseViewModel>();
using (DataClassesDataContext context = new DataClassesDataContext())
{
try
{
var purchases = context.XEROPurchases(searchFilter.StartDate, searchFilter.EndDate);
foreach (var purchase in purchases)
{
PurchaseViewModel purchaseViewModel = new PurchaseViewModel()
{
InvoiceNumber = purchase.InvoiceNumber,
EmailAddress = purchase.EmailAddress,
Address1 = purchase.POAddressLine1,
Address2 = purchase.POAddressLine2,
Address3 = purchase.POAddressLine3,
Address4 = purchase.POAddressLine4,
City = purchase.POCity,
Region = purchase.PORegion,
Country = purchase.POCountry,
PostalCode = purchase.POPostalCode,
InvoiceDate = purchase.InvoiceDate.GetValueOrDefault().ToString("dd-MM-yy"),
DueDate = purchase.DueDate.GetValueOrDefault().ToString("dd-MM-yy"),
InventoryItemCode = purchase.InventoryItemCode.ToString(),
Description = purchase.Description,
Quantity = purchase.Quantity.ToString(),
UnitAmount = purchase.UnitAmount.ToString(),
AccountCode = purchase.AccountCode.ToString(),
TaxType = purchase.TaxType,
TrackingName = purchase.TrackingName1,
TrackingOption = purchase.TrackingOption1,
Currency = purchase.Currency,
};
try
{
purchaseViewModel.ContactName = getSupplierName(purchase.ContactName);
}
catch(PurchaseValidationException e)
{
ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
}
catch (SupplierDoesNotExistException e )
{
ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
}
resultList.Add(purchaseViewModel);
}
}
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);
}
}