/// <summary> /// Create new customer based on the current class instance. Return True if Customer Created. /// </summary> /// <param name="iDpsCustomer"></param> /// <returns></returns> public async Task <bool> CreateNewCustomerAsync(IDpsCustomer iDpsCustomer) { try { // validation .... if (string.IsNullOrEmpty(this.Customer.VatNumber) || string.IsNullOrWhiteSpace(this.Customer.VatNumber)) { return(false); } else { string VatNumber = await iDpsCustomer.AddNewCustomerAsync(this); if (string.IsNullOrEmpty(VatNumber) || string.IsNullOrWhiteSpace(VatNumber)) { return(false); } return(true); } } catch (Exception e) { throw; } }
/// <summary> /// Create new customer based on the current class instance. Return True if Customer Created. /// </summary> /// <param name="iDpsCustomer"></param> /// <returns></returns> public async Task <bool> CreateNewCustomerAsync(IDpsCustomer iDpsCustomer, IBoemmApi iboemmApi) { try { // validation .... if (string.IsNullOrEmpty(this.Customer.VatNumber) || string.IsNullOrWhiteSpace(this.Customer.VatNumber)) { return(false); } else { string VatNumber = await iDpsCustomer.AddNewCustomerAsync(this); if (string.IsNullOrEmpty(VatNumber) || string.IsNullOrWhiteSpace(VatNumber)) { return(false); } var boemmCustomer = await iboemmApi.AddOrUpdateNewCustomerAsync(this.Customer); if (boemmCustomer != null) { // update DpsCustomer this.Customer = boemmCustomer; var Updated = await iDpsCustomer.UpdateCustomerAsync(this); if (!Updated) { // create a job or an indeication that this customer isn't updated to match boemm DB . but we have customer alredy. } } return(true); } } catch (Exception e) { throw; } }