public bool SaleItems(string _hostXeroApi, XeroInvoiceReportDTO request, ref string msg) { try { NSLog.Logger.Info("GenerateInvoice_Request: ", request); var result = (ResponseApiModels)ApiResponseXero.Post <ResponseApiModels>(_hostXeroApi + Commons.XeroApi_Sales_Item, null, request); NSLog.Logger.Info("GenerateInvoice_Response: ", result); if (result.Success) { //dynamic RawData = result.RawData; //var content = JsonConvert.SerializeObject(RawData); //var data = JsonConvert.DeserializeObject<XeroInvoiceResponseReportDTO>(content); return(true); } else { msg = result.Message; msg = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(msg); return(false); } } catch (Exception ex) { NSLog.Logger.Error("GenerateInvoice|Error: ", ex); return(false); } }
/// <summary> /// Get List Xero Setting /// </summary> /// <param name="StoreID"></param> /// <param name="ID"></param> /// <returns></returns> public List <XeroDTO> GetListXeroSetting(string StoreID = null, string ThirdPartyID = null, string Url = null, string ID = null) { List <XeroDTO> lstXeroDTO = new List <XeroDTO>(); XeroSettingApiModels paraBody = new XeroSettingApiModels(); paraBody.StoreId = StoreID; //paraBody.AppRegistrationId = Commons._XeroRegistrationAppId; paraBody.AppRegistrationId = ThirdPartyID; try { NSLog.Logger.Info("GetList_XeroSetting_Request: ", paraBody); var result = (ResponseApiModels)ApiResponseXero.Post <ResponseApiModels>(Url + "/" + Commons.XeroApi_GetSetting, null, paraBody); NSLog.Logger.Info("GetList_XeroSetting_Response: ", result); if (result.Success) { dynamic temp = result.RawData; var lstContent = JsonConvert.SerializeObject(temp /*result.RawData*/); lstXeroDTO = JsonConvert.DeserializeObject <List <XeroDTO> >(lstContent); } return(lstXeroDTO); } catch (Exception e) { NSLog.Logger.Info("GetList_XeroSetting", e); return(lstXeroDTO); } }
public List <SupplierXeroResponseModels> GetSupplierXero(string url, string AppRegistrationId, string StoreId, string ContactName, string ContactID, bool IsSupplier, ref string msg) { try { SupplierXeroRequestModels paraBody = new SupplierXeroRequestModels(); paraBody.AppRegistrationId = AppRegistrationId; paraBody.StoreId = StoreId; paraBody.ContactID = ContactID; paraBody.ContactName = ContactName; paraBody.IsSupplier = IsSupplier; NSLog.Logger.Info("GetSupplierXero_Request:", paraBody); var result = (ResponseApiModels)ApiResponseXero.Post <ResponseApiModels>(url + "/" + Commons.XeroApi_GetContacts, null, paraBody); if (result.Success) { dynamic RawData = result.RawData; var content = JsonConvert.SerializeObject(RawData); var data = JsonConvert.DeserializeObject <List <SupplierXeroResponseModels> >(content); NSLog.Logger.Info("GetSupplierXero_Response: ", data); return(data); } else { NSLog.Logger.Info("GetSupplierXero|Result[False]|Message: ", result.Message); msg = result.Message; msg = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(msg); return(null); } } catch (Exception ex) { NSLog.Logger.Error("GetSupplierXero | Error: ", ex); return(null); } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="AppRegistrationId">[6aaee02a-5dc0-466a-9352-5e9e279c1fe2]</param> /// <param name="StoreId">[NS-XERO-INTEGRATION]</param> /// <param name="msg"></param> /// <param name="data"></param> /// <returns></returns> public bool IngredientInsertUpdate(string _hostXeroApi, List <NSXeroIngredientModels> ListIng, string AppRegistrationId, string StoreId, ref string msg, ref NSXeroIngredientResponseModels data) { try { NSXeroIngredientRequestModels paraBody = new NSXeroIngredientRequestModels(); paraBody.AppRegistrationId = AppRegistrationId; paraBody.StoreId = StoreId; paraBody.Ingredients = ListIng; NSLog.Logger.Info("IngredientInsertUpdate_Request: ", paraBody); var result = (ResponseApiModels)ApiResponseXero.Post <ResponseApiModels>(_hostXeroApi + Commons.XeroApi_Ingredient_Insert_Update, null, paraBody); if (result.Success) { dynamic RawData = result.RawData; var content = JsonConvert.SerializeObject(RawData); data = JsonConvert.DeserializeObject <NSXeroIngredientResponseModels>(content); NSLog.Logger.Info("IngredientInsertUpdate_Response: ", data); return(true); } else { //Get List Error dynamic RawData = result.RawData; var content = JsonConvert.SerializeObject(RawData); List <IngError> listMsg = JsonConvert.DeserializeObject <List <IngError> >(content); result.Message = string.Join("|", listMsg.Select(x => x.Message)); NSLog.Logger.Info("IngredientInsertUpdate|Result[False]|Message: ", result.Message); msg = result.Message; msg = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(msg); return(false); } } catch (Exception ex) { NSLog.Logger.Error("IngredientInsertUpdate|Error: ", ex); return(false); } }
public List <TaxXeroModels> GetTaxXero(TaxXeroRequestModels item) { List <TaxXeroModels> listdata = new List <TaxXeroModels>(); try { var result = (ResponseApiModels)ApiResponseXero.Post <ResponseApiModels>(item.ApiURL + "/" + Commons.XeroApi_GetTax, null, item); dynamic data = result; if (data.Success) { var lstZ = data.RawData; var lstContent = JsonConvert.SerializeObject(lstZ); listdata = JsonConvert.DeserializeObject <List <TaxXeroModels> >(lstContent); } return(listdata); } catch (Exception e) { _logger.Error("GetTaxXero_GetList: " + e); return(listdata); } }
/// <summary> /// Function [GeneratePO] /// </summary> /// <param name="_hostXeroApi"></param> /// <param name="request"></param> /// <param name="msg"></param> /// <returns></returns> public bool GeneratePO(string _hostXeroApi, GeneratePOModels request, ref string msg) { try { NSLog.Logger.Info("POInsertUpdate_Request: ", request); var result = (ResponseApiModels)ApiResponseXero.Post <ResponseApiModels>(_hostXeroApi + "/" + Commons.XeroApi_PO_Insert_Update, null, request); NSLog.Logger.Info("POInsertUpdate_Response: ", result); if (result.Success) { return(true); } else { msg = result.Message; msg = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(msg); return(false); } } catch (Exception ex) { NSLog.Logger.Error("POInsertUpdate|Error: ", ex); return(false); } }
public bool CreateOrUpdateSupplier(string url, SupplierXeroModels models, string SupplierId, ref string msg) { try { SupplierXeroRequestModels paraBody = new SupplierXeroRequestModels(); paraBody.AccessToken = models.AccessToken; paraBody.AppRegistrationId = models.AppRegistrationId; paraBody.StoreId = models.StoreId; paraBody.Contact = models.Contact; NSLog.Logger.Info("CreateOrUpdateSupplier_Request:", paraBody); var result = (ResponseApiModels)ApiResponseXero.Post <ResponseApiModels>(url + "/" + Commons.XeroApi_InsertOrUpdateSupplier, null, paraBody); if (result.Success) { dynamic RawData = result.RawData; var content = JsonConvert.SerializeObject(RawData); SupplierXeroResponseModels data = JsonConvert.DeserializeObject <SupplierXeroResponseModels>(content); string ContactID = data.ContactID; //----Update XeroId for Supplier using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { var itemUpdate = (from tb in cxt.I_Supplier where tb.Id == SupplierId select tb).FirstOrDefault(); if (itemUpdate != null) { itemUpdate.XeroId = ContactID; cxt.SaveChanges(); transaction.Commit(); } } catch (Exception ex) { NSLog.Logger.Error("UpdateXeroIdSupplier|Error: ", ex); transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } NSLog.Logger.Info("CreateOrUpdateSupplier_Response: ", data); return(true); } else { NSLog.Logger.Info("CreateOrUpdateSupplier|Result[False]|Message: ", result.Message); msg = result.Message; msg = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(msg); return(false); } } catch (Exception ex) { NSLog.Logger.Error("CreateOrUpdateSupplier|Error: ", ex); return(false); } }