Ejemplo n.º 1
0
        private void AvailableSalesmanListView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if ((sender as ListView).SelectedItem is Salesman item)
            {
                Salesman salesman = new Salesman
                {
                    salesman_ID = item.salesman_ID,
                    name        = item.name,
                };

                District selectedDistrict = (District)districtListView.SelectedItem;

                DistrictsController.AddSecondarySalesman(selectedDistrict.district_ID, item.salesman_ID);

                List <Salesman>[] salesmen = DistrictsController.GetSecondarySalesmenForDistrict(selectedDistrict.district_ID);

                secondarySalesmanListView.ItemsSource = null;
                availableSalesmanListView.ItemsSource = null;

                secondarySalesmanListView.Items.Clear();
                availableSalesmanListView.Items.Clear();


                secondarySalesmanListView.ItemsSource = salesmen[0];
                availableSalesmanListView.ItemsSource = salesmen[1];
            }
        }
Ejemplo n.º 2
0
        private void ChooseResponsibleSalesmanComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((sender as ComboBox).SelectedItem is Salesman item)
            {
                Salesman salesman = new Salesman
                {
                    salesman_ID = item.salesman_ID,
                    name        = item.name,
                };

                District selectedDistrict = (District)districtListView.SelectedItem;

                DistrictsController.UpdateResponsibleSalesman(selectedDistrict.district_ID, item.salesman_ID);

                List <Salesman>[] responsibleSalesmen = DistrictsController.GetResponsibleSalesmenForDistrict(selectedDistrict.district_ID);

                responsibleSalesmanListView.ItemsSource       = null;
                ChooseResponsibleSalesmanComboBox.ItemsSource = null;

                responsibleSalesmanListView.Items.Clear();
                ChooseResponsibleSalesmanComboBox.Items.Clear();

                responsibleSalesmanListView.ItemsSource       = responsibleSalesmen[0];
                ChooseResponsibleSalesmanComboBox.ItemsSource = responsibleSalesmen[1];
            }
        }
Ejemplo n.º 3
0
        public void GetCitiesReturnListOfCities()
        {
            //Arrange
            var moq = new Mock <IDistrictsRepository>();

            moq.Setup(m => m.GetCities(It.IsAny <int>())).Returns(Task.FromResult(new List <City>() as IEnumerable <City>));
            DistrictsController controller = new DistrictsController(moq.Object);

            //Act
            var result = controller.GetCities(3).Result;

            //Assert
            Assert.IsInstanceOfType(result, typeof(IEnumerable <City>));
        }
Ejemplo n.º 4
0
        private void DistrictListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((sender as ListView).SelectedItem is District item)
            {
                storeListView.ItemsSource = DistrictsController.GetStoresForDistrict(item.district_ID);

                List <Salesman>[] secondarySalesmen = DistrictsController.GetSecondarySalesmenForDistrict(item.district_ID);
                secondarySalesmanListView.ItemsSource = secondarySalesmen[0];
                availableSalesmanListView.ItemsSource = secondarySalesmen[1];


                List <Salesman>[] responsibleSalesmen = DistrictsController.GetResponsibleSalesmenForDistrict(item.district_ID);

                responsibleSalesmanListView.ItemsSource       = responsibleSalesmen[0];
                ChooseResponsibleSalesmanComboBox.ItemsSource = responsibleSalesmen[1];
            }
        }
Ejemplo n.º 5
0
        public void GetIdReturnsDistrict()
        {
            //Arrange
            var moq = new Mock <IDistrictsRepository>();

            moq.Setup(m => m.Get(It.IsAny <object[]>())).Returns <object[]>(id => Task.FromResult(new District {
                Id = (int)id[0]
            }));
            DistrictsController controller = new DistrictsController(moq.Object);
            int districtId = 3;

            //Act
            var result = controller.Get(districtId).Result;

            //Assert
            Assert.IsInstanceOfType(result, typeof(District));
            Assert.AreEqual(districtId, result.Id);
        }