private void GetLiveBusinessPartners()
        {
            try
            {
                var criteria = new SearchCriteria <BusinessPartnerDTO>
                {
                    TransactionType = (int)Transaction
                };

                var bpList = new BusinessPartnerService()
                             .GetAll(criteria)
                             .OrderBy(i => i.Id)
                             .ToList();

                if (bpList.Count > 1)
                {
                    bpList.Insert(0, new BusinessPartnerDTO
                    {
                        DisplayName = "All",
                        Id          = -1
                    });
                }

                BusinessPartners = new ObservableCollection <BusinessPartnerDTO>(bpList);
            }
            catch (Exception exception)
            {
                System.Windows.MessageBox.Show("Can't Load Business Partner"
                                               + Environment.NewLine + exception.Message, "Can't Get ", MessageBoxButton.OK,
                                               MessageBoxImage.Error);
            }
        }
        public async Task BusinessPartnerService_ShouldBeAddTaskInQueue()
        {
            var businessPartnerValidations = new List <IBusinessPartnerValidation>
            {
                new BusinessPartnerForArValidation(Mock.Of <ILogger <BusinessPartnerForArValidation> >()),
                new BusinessPartnerForUsValidation(Mock.Of <ILogger <BusinessPartnerForUsValidation> >())
            };

            var loggerMock         = new Mock <ILogger <BusinessPartnerService> >();
            var queuingServiceMock = new Mock <IQueuingService>();

            var sapConfigMock = new Mock <IOptions <SapConfig> >();

            sapConfigMock.Setup(x => x.Value)
            .Returns(new SapConfig
            {
                SapServiceConfigsBySystem = new Dictionary <string, SapServiceConfig>
                {
                    { "AR", new SapServiceConfig {
                          CompanyDB             = "CompanyDb",
                          Password              = "******",
                          UserName              = "******",
                          BaseServerUrl         = "http://123.123.123/",
                          BusinessPartnerConfig = new BusinessPartnerConfig
                          {
                              Endpoint = "BusinessPartners"
                          }
                      } },
                    { "US", new SapServiceConfig {
                          CompanyDB             = "CompanyDb",
                          Password              = "******",
                          UserName              = "******",
                          BaseServerUrl         = "http://123.123.123/",
                          BusinessPartnerConfig = new BusinessPartnerConfig
                          {
                              Endpoint = "BusinessPartners"
                          }
                      } }
                }
            });

            var businessPartnerService = new BusinessPartnerService(queuingServiceMock.Object, loggerMock.Object, sapConfigMock.Object, businessPartnerValidations);

            var dopplerUser = new DopplerUserDto
            {
                Id              = 1,
                FirstName       = "Juan",
                LastName        = "Perez",
                FederalTaxID    = "27111111115",
                PlanType        = 1,
                BillingSystemId = 2
            };

            await businessPartnerService.CreateOrUpdateBusinessPartner(dopplerUser);

            queuingServiceMock.Verify(x => x.AddToTaskQueue(It.IsAny <SapTask>()), Times.Once);
        }
Exemple #3
0
        public MainViewModel(
            BusinessPartnerService service,
            BusinessPartnerListViewModel listView,
            BusinessPartnerDataViewModel dataView)
        {
            _businessPartnerService = service;

            BusinessPartnerList = listView;
            BusinessPartnerList.Attach(dataView);
            BusinessPartnerData = dataView;
            BusinessPartnerData.Attach(listView);
        }
Exemple #4
0
 public List<BusinessPartner> GetAll(string name)
 {
     BusinessPartnerService bpService = new BusinessPartnerService();
     List<BusinessPartner> list = new List<BusinessPartner>();
     List<object> parameters = new List<object>();
     string queryStr = "it.IsDeleted = false and (it.ApproveStatus = " + (int)ApproveStatus.Approved + " or it.ApproveStatus = " + (int)ApproveStatus.NoApproveNeeded + ")";
     if (!string.IsNullOrEmpty(name))
     {
         queryStr += " and it.ShortName Like @p1";
         parameters.Add("%" + name + "%");
     }
     list = bpService.Query(queryStr, parameters.Count > 0 ? parameters : null).ToList();
     return list;
 }
        public void BusinessPartnerService_ShouldBeThrowsValidationException_WhenDopplerUserFirstNameAndLastNameAreNotValidAndSapAr()
        {
            var businessPartnerValidations = new List <IBusinessPartnerValidation>
            {
                new BusinessPartnerForArValidation(Mock.Of <ILogger <BusinessPartnerForArValidation> >()),
                new BusinessPartnerForUsValidation(Mock.Of <ILogger <BusinessPartnerForUsValidation> >())
            };

            var loggerMock         = new Mock <ILogger <BusinessPartnerService> >();
            var queuingServiceMock = new Mock <IQueuingService>();

            var sapConfigMock = new Mock <IOptions <SapConfig> >();

            sapConfigMock.Setup(x => x.Value)
            .Returns(new SapConfig
            {
                SapServiceConfigsBySystem = new Dictionary <string, SapServiceConfig>
                {
                    { "AR", new SapServiceConfig {
                          CompanyDB             = "CompanyDb",
                          Password              = "******",
                          UserName              = "******",
                          BaseServerUrl         = "http://123.123.123/",
                          BusinessPartnerConfig = new BusinessPartnerConfig
                          {
                              Endpoint = "BusinessPartners"
                          }
                      } }
                }
            });

            var businessPartnerService = new BusinessPartnerService(queuingServiceMock.Object, loggerMock.Object, sapConfigMock.Object, businessPartnerValidations);

            var dopplerUser = new DopplerUserDto
            {
                Id                 = 1,
                FirstName          = "",
                LastName           = "",
                FederalTaxID       = "123",
                PlanType           = 1,
                BillingCountryCode = "AR",
                BillingSystemId    = 9
            };

            var ex = Assert.ThrowsAsync <ValidationException>(() => businessPartnerService.CreateOrUpdateBusinessPartner(dopplerUser));

            Assert.Equal("Invalid first name or last name.", ex.Result.Message);
        }
Exemple #6
0
        public void BusinessPartnerService_ShouldBeThrowsArgumentException_WhenCountryCodeNotAROrUS()
        {
            var businessPartnerValidations = new List <IBusinessPartnerValidation>
            {
                new BusinessPartnerForArValidation(Mock.Of <ILogger <BusinessPartnerForArValidation> >()),
                new BusinessPartnerForUsValidation(Mock.Of <ILogger <BusinessPartnerForUsValidation> >())
            };

            var loggerMock         = new Mock <ILogger <BusinessPartnerService> >();
            var queuingServiceMock = new Mock <IQueuingService>();

            var sapConfigMock = new Mock <IOptions <SapConfig> >();

            sapConfigMock.Setup(x => x.Value)
            .Returns(new SapConfig
            {
                SapServiceConfigsBySystem = new Dictionary <string, SapServiceConfig>
                {
                    { "AR", new SapServiceConfig {
                          CompanyDB             = "CompanyDb",
                          Password              = "******",
                          UserName              = "******",
                          BaseServerUrl         = "http://123.123.123/",
                          BusinessPartnerConfig = new BusinessPartnerConfig
                          {
                              Endpoint = "BusinessPartners"
                          }
                      } }
                }
            });

            var businessPartnerService = new BusinessPartnerService(queuingServiceMock.Object, loggerMock.Object, sapConfigMock.Object, businessPartnerValidations);

            var dopplerUser = new DopplerUserDto
            {
                Id                 = 1,
                FederalTaxID       = "27111111115",
                PlanType           = 1,
                BillingCountryCode = "MX",
                BillingSystemId    = 16
            };

            var ex = Assert.ThrowsAsync <ArgumentException>(() => businessPartnerService.CreateOrUpdateBusinessPartner(dopplerUser));

            Assert.Equal("sapSystem (Parameter 'The sapSystem '' is not supported.')", ex.Result.Message);
        }
Exemple #7
0
        public ActionResult GetBps(string bpType)
        {
            var businessPartnerType = (BusinessPartnerTypes)Convert.ToInt32(bpType);
            var criteria            = new SearchCriteria <BusinessPartnerDTO>();

            criteria.FiList.Add(b => b.BusinessPartnerType == businessPartnerType);

            IEnumerable <BusinessPartnerDTO> bps = new BusinessPartnerService(true)
                                                   .GetAll(criteria);
            IList <ListViewModel> bpVms = bps.Select(bpDTO => new ListViewModel()
            {
                Name = bpDTO.DisplayName,
                Id   = bpDTO.Id
            }).ToList();

            return(Json(bpVms, JsonRequestBehavior.AllowGet));
        }
        private void GetLiveBusinessPartners()
        {
            var criteria = new SearchCriteria <BusinessPartnerDTO>
            {
                TransactionType = (int)Transaction
            };

            IList <BusinessPartnerDTO> bpList = new BusinessPartnerService(true)
                                                .GetAll(criteria)
                                                .OrderByDescending(i => i.Id)
                                                .ToList();

            if (bpList.Count > 1)
            {
                bpList.Insert(0, new BusinessPartnerDTO
                {
                    DisplayName = "All",
                    Id          = -1
                });
            }
            BusinessPartners = new ObservableCollection <BusinessPartnerDTO>(bpList);
        }
Exemple #9
0
 public List<BusinessPartner> GetInternalCustomersByUserId(int userId)
 {
     BusinessPartnerService bpService = new BusinessPartnerService();
     return bpService.GetInternalCustomersByUser(userId);
 }
Exemple #10
0
 public BusinessPartnerController(BusinessPartnerService service)
 {
     this.db = service;
 }
Exemple #11
0
 public BusinessPartnerDataViewModel(BusinessPartnerService service)
 {
     _service = service;
 }