public async Task Test_Create_Customer()
        {
            var trackingApiService = new TrackerApiService(true);
            var response           = await trackingApiService.CreateCustomer(new CreateCustomerRequest()
            {
                CustomerName    = "TRANSNATIONAL LANKA RECORD SOLUTIONS (PVT) LTD",
                CustomerAddress = "#55/60, VAUXHALL LANE, COLOMBO 02.",
                ContactNumber   = "0117574574",
                EmailAddress    = "*****@*****.**",
                NicNo           = "000000000v",
                ContactPerson   = "MR. VIHANGA HETTIARACHCHI",
                InvoicingHub    = "0001",
                TaxRegNo        = "100001100-2525",
                Vat             = "1",
                Remarks         = "Remarks",
                CreatedDate     = System.DateTime.Now,
                TplSupplierCode = "1000005"
            });

            Assert.IsTrue(response.IsSuccess.Equals("1"));
        }
        public async Task <Dal.Entities.Supplier> AddSupplier(Dal.Entities.Supplier supplier)
        {
            Guard.Argument(supplier, nameof(supplier)).NotNull();

            await ValidateSupplier(supplier);

            await using var transaction = await _unitOfWork.GetTransaction();

            try
            {
                _unitOfWork.SupplierRepository.Insert(supplier);
                await _unitOfWork.SaveChanges();

                var savedSupplier = await GetSupplierById(supplier.Id);

                var response = await _trackerApiService.CreateCustomer(new CreateCustomerRequest()
                {
                    CustomerName    = savedSupplier.SupplierName,
                    CustomerAddress =
                        $"{savedSupplier.Address.AddressLine1} {savedSupplier.Address.AddressLine2} {savedSupplier.Address.City.CityName} {savedSupplier.Address.PostalCode}",
                    ContactNumber   = savedSupplier.Contact.Phone,
                    EmailAddress    = savedSupplier.Contact.Email,
                    NicNo           = string.Empty,
                    ContactPerson   = savedSupplier.Contact.ContactPerson,
                    TaxRegNo        = savedSupplier.VatNumber,
                    Vat             = string.IsNullOrEmpty(savedSupplier.VatNumber) ? "0" : "1",
                    Remarks         = string.Empty,
                    CreatedDate     = System.DateTime.Now,
                    TplSupplierCode = savedSupplier.Code
                });

                if (response.IsSuccess != "1")
                {
                    throw new ServiceException(new ErrorMessage[]
                    {
                        new ErrorMessage()
                        {
                            Code    = string.Empty,
                            Message = $"Unable to create a supplier in tracker side"
                        }
                    });
                }

                savedSupplier.TrackerCode = response.Result.CustomerCode;
                await _unitOfWork.SaveChanges();

                await transaction.CommitAsync();
            }
            catch (TrackingApiException ex)
            {
                await transaction.RollbackAsync();

                throw new ServiceException(new ErrorMessage[]
                {
                    new ErrorMessage()
                    {
                        Code    = string.Empty,
                        Message = $"Unable to create a supplier in tracker side"
                    }
                });
            }
            catch
            {
                await transaction.RollbackAsync();

                throw;
            }

            return(await GetSupplierById(supplier.Id));
        }