Пример #1
0
        /// <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;
            }
        }
Пример #2
0
        public async Task <DpsCustomer> GetCustomerByVatNumberAsync(string Vat, IDpsCustomer idpsCustomer)
        {
            var localDpsCustomer = await idpsCustomer.GetCustomerByVatNumberAsync(Vat);

            if (localDpsCustomer != null)
            {
                return(localDpsCustomer);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        /// <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;
            }
        }
Пример #4
0
        public async Task <DpsCustomer> GetCustomerByVatNumberAsync(string Vat, IDpsCustomer idpsCustomer, IBoemmApi iboemmApi)
        {
            var localDpsCustomer = await idpsCustomer.GetCustomerByVatNumberAsync(Vat);

            if (localDpsCustomer != null)
            {
                return(localDpsCustomer);
            }
            else
            {
                var BoemmCustomer = await iboemmApi.GetBoemmCustomerByVatNumberAsync(Vat);

                if (BoemmCustomer != null)
                {
                    DpsCustomer dpsCustomer = new DpsCustomer();
                    dpsCustomer.Customer = BoemmCustomer;
                    return(dpsCustomer);
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #5
0
 public async Task <List <DpsCustomer> > GetAllCustomersAsync(IDpsCustomer idpsCustomer)
 {
     return(await idpsCustomer.GetAllCustomersAsync());
 }
Пример #6
0
        public async Task <List <Tuple <string, string, string> > > GetCustomerVatAndNameAsync(IDpsCustomer idpsCustomer)
        {
            var allCustomers = await idpsCustomer.GetAllCustomersAsync();

            var Model = new List <Tuple <string, string, string> >();

            foreach (var customer in allCustomers)
            {
                Model.Add(new Tuple <string, string, string>(customer.Customer.VatNumber, customer.Customer.Name, customer.Customer.OfficialName));
            }
            return(Model);
        }
Пример #7
0
 public async Task <DpsCustomer> GetCustomerByVatNumberAsync(string Vat, IDpsCustomer idpsCustomer)
 {
     return(await idpsCustomer.GetCustomerByVatNumberAsync(Vat));
 }