Пример #1
0
        public void GetOffersFilter()
        {
            int      id            = 0;
            DateTime dateOfPosting = DateTime.Now;
            string   from          = "Ukraine";
            string   to            = "Poland";
            DateTime dateOfLoading = DateTime.Now;
            Vehicle  vehicle       = new Vehicle()
            {
                VehicleId = 1,
                Type      = VehicleType.Box,
                Weight    = 25
            };
            Carrier carrier = new Carrier()
            {
                CarrierId   = 1,
                Name        = "John",
                Email       = "*****@*****.**",
                PhoneNumber = "+123456789",
                VehicleId   = 1,
                Vehicle     = vehicle
            };
            Offer offer = new Offer()
            {
                OfferId       = id,
                DateOfLoading = dateOfLoading,
                DateOfPosting = dateOfPosting,
                From          = from,
                To            = to,
                CarrierId     = 1,
                Carrier       = carrier
            };

            Filter filter = new Filter(

                minDateOfPosting: dateOfPosting,
                from: from,
                type: vehicle.Type,
                maxWeight: vehicle.Weight
                );

            OfferController offerController = new OfferController();

            offerController.AddOffer(offer);
            var res = offerController.GetOffers(filter);

            Assert.IsTrue(res.Count == 1);
        }
Пример #2
0
        /// <summary>
        /// Button Click.
        /// </summary>
        /// <param name="sender">Just Object.</param>
        /// <param name="e">MouseButtonEventArgs e.</param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Filter f = new Filter(
                    from: this.fromCountry.Text != string.Empty ? this.fromCountry.Text : null,
                    to: this.toCountry.Text != string.Empty ? this.toCountry.Text : null,
                    minDateOfLoading: this.dateFrom.SelectedDate,
                    maxDateOfLoading: this.dateTo.SelectedDate,
                    type: (VehicleType?)(this.expander1.SelectedIndex - 1),
                    minWeight: double.TryParse(this.weightFrom.Text, out double res1) ? res1 as double? : null,
                    maxWeight: double.TryParse(this.weightTo.Text, out double res2) ? res2 as double? : null);

                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    OfferController offerController = new OfferController(new List <Offer>(unitOfWork.Offers.GetAll()));
                    this.dataList.ItemsSource = offerController.GetOffers(f);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Unexpected error occured");
            }
        }