Exemplo n.º 1
0
 public Buyers()
 {
     InitializeComponent();
     carShowroom1 = new CarShowroom();
     carShowroom1.Load();
     buyerBindingSource.DataSource = carShowroom1.Buyers;
 }
Exemplo n.º 2
0
 public Application()
 {
     InitializeComponent();
     carShowroom1         = new CarShowroom();
     carShowroom1.IfSaved = false;
     carInApplicBindingSource.DataSource = carShowroom1.Application;
 }
Exemplo n.º 3
0
 public Reports()
 {
     InitializeComponent();
     carShowroom1 = new CarShowroom();
     carShowroom1.Load();
     reportBindingSource.DataSource = carShowroom1.Reports;
 }
        public async void UpdateCarShowroom(CarShowroom carshowroom)
        {
            try
            {
                Task <CarShowroom> newCarShowroomTask = GetCarShowroom(carshowroom.CarShowroomId);
                CarShowroom        newCarShowroom     = await newCarShowroomTask;

                if (newCarShowroom == null)
                {
                    throw new EntryPointNotFoundException("Vehiclee Not found in database");
                }

                newCarShowroom.Name        = carshowroom.Name;
                newCarShowroom.MaxCapacity = carshowroom.MaxCapacity;

                using (HttpResponseMessage response = await ApiHelper.ApiClient.PutAsJsonAsync("api/CarShowrooms/" + carshowroom.CarShowroomId, newCarShowroom))
                {
                    if (response.IsSuccessStatusCode)
                    {
                    }
                    else
                    {
                        throw new Exception(response.ReasonPhrase);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        public void SimilarOptionsInStock_Test(string[] brand, string[] model, string[] typeOfBody, string[] transmissionType, string[] engineType, string[] volume, string[] power, string[] climateContro, string[] salonType, string wayToCatalog, string wayToStock)
        {
            CarShowroom salon = new CarShowroom(wayToCatalog, wayToStock);

            salon.ReadJsonFile();
            Invoker        newInvoker = new Invoker();
            ProspectiveCar result     = new ProspectiveCar();
            ProspectiveCar wantedCar  = new ProspectiveCar();

            wantedCar.mark             = brand[0];
            wantedCar.model            = model[0];
            wantedCar.typeOfBody       = typeOfBody[0];
            wantedCar.transmissionType = transmissionType[0];
            wantedCar.engineType       = engineType[0];
            wantedCar.volume           = volume[0];
            wantedCar.power            = power[0];
            wantedCar.climateControl   = climateContro[0];
            wantedCar.salonType        = salonType[0];
            newInvoker.SetCommand(new SimilarOptionsInStock(salon, wantedCar));
            List <Car> similarCars = new List <Car>(newInvoker.Execute());

            Assert.True(similarCars[0].GetType().Name == brand[0] && similarCars[0].model == model[1] && similarCars[0].typeOfBody == typeOfBody[1] &&
                        similarCars[0].transmissionType == transmissionType[1] && similarCars[0].engineType == engineType[1] && similarCars[0].volume == volume[1] &&
                        similarCars[0].power == power[1] && similarCars[0].climateControl == climateContro[1] && similarCars[0].salonType == salonType[1]);
        }
Exemplo n.º 6
0
        public void AddingItemToFile_Test(string brand, string model, string typeOfBody, string transmissionType, string engineType, string volume, string power, string climateControl, string salonType, string wayToCatalog, string wayToStock)
        {
            CarShowroom salon = new CarShowroom(wayToCatalog, wayToStock);

            salon.ReadJsonFile();
            Invoker        newInvoker = new Invoker();
            ProspectiveCar result     = new ProspectiveCar();
            ProspectiveCar wantedCar  = new ProspectiveCar();

            wantedCar.mark             = brand;
            wantedCar.model            = model;
            wantedCar.typeOfBody       = typeOfBody;
            wantedCar.transmissionType = transmissionType;
            wantedCar.engineType       = engineType;
            wantedCar.volume           = volume;
            wantedCar.power            = power;
            wantedCar.climateControl   = climateControl;
            wantedCar.salonType        = salonType;
            newInvoker.SetCommand(new AddingItemToFile(salon, wantedCar));
            List <Car> similarCars = new List <Car>(newInvoker.Execute());
            int        lastElent   = similarCars.Count - 1;

            Assert.True(similarCars[lastElent].GetType().Name == brand && similarCars[lastElent].model == model && similarCars[lastElent].typeOfBody == typeOfBody &&
                        similarCars[lastElent].transmissionType == transmissionType && similarCars[lastElent].engineType == engineType && similarCars[lastElent].volume == volume &&
                        similarCars[lastElent].power == power && similarCars[lastElent].climateControl == climateControl && similarCars[lastElent].salonType == salonType);
        }
Exemplo n.º 7
0
        public async Task <ActionResult <CarShowroom> > PostCarShowroom(CarShowroom carShowroom)
        {
            try
            {
                CarShowroom newCarShowroom = new CarShowroom();

                if (!_context.CarShowroomContainers.Where(c => c.CarShowroomContainerId == carShowroom.CarShowroomContainerId).Any())
                {
                    throw new Exception("Wrong CarShowroomContainer Id was selected.");
                }
                else
                {
                    newCarShowroom.CarShowroomContainerId = carShowroom.CarShowroomContainerId;
                }

                newCarShowroom.Name        = carShowroom.Name;
                newCarShowroom.MaxCapacity = carShowroom.MaxCapacity;
                //newCarShowroom.CarList = new List<Vehicle>();

                _context.CarShowrooms.Add(newCarShowroom);
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetCarShowroom", new { id = carShowroom.CarShowroomId }, carShowroom));
            }
            catch (Exception e)
            {
                // ignore
                return(Ok());
            }
        }
Exemplo n.º 8
0
 public FindBest()
 {
     InitializeComponent();
     carShowroom1 = new CarShowroom();
     carShowroom1.Load();
     carBindingSource.DataSource = carShowroom1.Cars;
 }
Exemplo n.º 9
0
 public BuyerAllCars()
 {
     carShowroom1 = new CarShowroom();
     InitializeComponent();
     carShowroom1.Load();
     carBindingSource.DataSource = carShowroom1.Cars;
 }
Exemplo n.º 10
0
 public BuyerAllCars(Buyer curent)
 {
     carShowroom1 = new CarShowroom();
     InitializeComponent();
     carShowroom1.Load();
     carBindingSource.DataSource = carShowroom1.Cars;
     this.CurentBuyer            = curent;
 }
Exemplo n.º 11
0
 public AdmListCars()
 {
     InitializeComponent();
     carShowroom1 = new CarShowroom();
     //CarShowroom1.FillTestData(100);
     carShowroom1.Load();
     carBindingSource.DataSource = carShowroom1.Cars;
 }
Exemplo n.º 12
0
        /// <summary>
        /// Main method
        /// </summary>
        static void Main()
        {
            CarShowroom carShowroom = new CarShowroom();

            ClientManager clientManager = new ClientManager(carShowroom);

            clientManager.SetListOfCars();
            clientManager.ChooseCommand();
        }
Exemplo n.º 13
0
 public FindBest(Buyer curent)
 {
     InitializeComponent();
     carShowroom1 = new CarShowroom();
     carShowroom1.Load();
     CurentBuyer = curent;
     carShowroom1.FindAllthebest(CurentBuyer);
     carBindingSource.DataSource = carShowroom1.ShoppingCart;
 }
Exemplo n.º 14
0
        public void TestBuyerPass()//тестирует правильность работы метода для составления паролей;
        {
            CarShowroom1 = new CarShowroom();
            int n = 50;

            CarShowroom1.FillTestData(n);
            foreach (var b in CarShowroom1.Buyers)
            {
                Assert.IsTrue(b.Password.Length >= 3);
                Assert.IsTrue(b.Name.Length >= 3);
            }
        }
Exemplo n.º 15
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            Task <List <CarShowroomContainer> > salonContainerTask = _carShowroomContainerControler.GetCarShowroomContainer();
            List <CarShowroomContainer>         salonCon           = await salonContainerTask;

            this.salonContainer = new CarShowroomContainer();
            BookedVehicles      = new List <Vehicle>();

            Task <List <CarShowroom> > salonsTask = _carShowroomControler.GetCarshowrooms();
            List <CarShowroom>         salonsList = await salonsTask;

            Task <List <Vehicle> > vehiclesTask = _vehicleControler.GetVehicles();
            List <Vehicle>         vehicles     = await vehiclesTask;

            foreach (var salon in salonsList)
            {
                salonContainer.salons.Add(salon);
                CentersComboBox.Items.Add(salon.Name);
            }

            foreach (var vehicle in vehicles)
            {
                var salon = salonContainer.salons.Where(n => n.Name == vehicle.SalonName).FirstOrDefault();
                if (salon == null)
                {
                    salon.CarList.Add(vehicle);
                }
            }

            foreach (var vehicle in vehicles)
            {
                var salon = salonContainer.salons.Where(n => n.Name == vehicle.SalonName).FirstOrDefault();
                if (salon == null)
                {
                    if (vehicle.Booked == true)
                    {
                        BookedVehicles.Add(vehicle);
                    }
                }
            }

            CarShowroom newc = new CarShowroom("Dowolny", 20);

            newc.CarList.AddRange(vehicles);
            salonContainer.salons.Add(newc);
            CentersComboBox.Items.Add(newc.Name);


            FillVehicleListData();
            FillKoszykList();
            AvrgRatingLabel.Hide();
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            Car             carModel1            = new Car("baleno", "suzuki", 4, "XUV", 400000f);
            Car             carModel2            = new Car("City", "Honda", 4, "XUV", 550000f);
            SortedSet <Car> listOfCarsInShowroom = new SortedSet <Car>();

            listOfCarsInShowroom.Add(carModel1);
            listOfCarsInShowroom.Add(carModel2);
            CarShowroom carShowRoomInstance = new CarShowroom("Wasan Motors", "Mumbai", "Alex ceaser", listOfCarsInShowroom);

            PrintCarShowRoomDetails(carShowRoomInstance);
            Console.ReadLine();
        }
Exemplo n.º 17
0
 public async void AddCarShowroom(CarShowroom carshowroom)
 {
     using (HttpResponseMessage response = await ApiHelper.ApiClient.PostAsJsonAsync("api/CarShowroom", carshowroom))
     {
         if (response.IsSuccessStatusCode)
         {
         }
         else
         {
             throw new Exception(response.ReasonPhrase);
         }
     }
 }
Exemplo n.º 18
0
        public void AddingItemToFile_Exception(string wayToCatalog, string wayToStock)
        {
            CarShowroom salon = new CarShowroom(wayToCatalog, wayToStock);

            salon.ReadJsonFile();
            Invoker        newInvoker = new Invoker();
            ProspectiveCar wantedCar  = new ProspectiveCar();

            newInvoker.SetCommand(new AddingItemToFile(salon, wantedCar));
            Assert.Throws <ArgumentOutOfRangeException>
            (
                () => newInvoker.Execute()
            );
        }
Exemplo n.º 19
0
 private void Register_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult != DialogResult.OK)
     {
         return;
     }
     ChekPass(NametextBox, e);
     ChekPass(PastextBox, e);
     if (e.Cancel != false)
     {
         MessageBox.Show("Password and login must be at least 3 characters and no more than 12", "Attention!");
     }
     ChekText(ContacttextBox, e);
     if (e.Cancel == false)
     {
         CarShowroom CarShowroom1 = new CarShowroom();
         CarShowroom1.Load();
         if (BuyerN != NametextBox.Text)
         {
             foreach (var b in CarShowroom1.Buyers)
             {
                 if (b.Name.Equals(NametextBox.Text))
                 {
                     e.Cancel = true;
                     NametextBox.BackColor = Color.LightPink;
                     MessageBox.Show("User with the same name already exists", "Attantion!", MessageBoxButtons.OK);
                 }
             }
         }
         if (e.Cancel == false)
         {
             if (Buyer == null)
             {
                 Buyer = new Buyer();
             }
             Buyer.Contacts          = ContacttextBox.Text;
             Buyer.FinancialOpp      = Convert.ToInt32(Prise_numericUp.Value);
             Buyer.MaksSpeedRequired = Convert.ToInt32(Speed_numeric.Value);
             Buyer.ModelRequired     = ModelcomboBox.Text;
             Buyer.Name               = NametextBox.Text;
             Buyer.Password           = PastextBox.Text;
             Buyer.PerfomanceRequired = Convert.ToInt32(Perf_numeric.Value);
             if (string.IsNullOrWhiteSpace(ModelcomboBox.Text))
             {
                 Buyer.ModelRequired = "nope";
             }
         }
     }
 }
Exemplo n.º 20
0
        public async Task <CarShowroom> GetCarShowroom(int carshowroomId)
        {
            using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync("api/CarShowrooms/" + carshowroomId))
            {
                if (response.IsSuccessStatusCode)
                {
                    CarShowroom carShowroom = await response.Content.ReadAsAsync <CarShowroom>();

                    return(carShowroom);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
Exemplo n.º 21
0
        public static void PrintCarShowRoomDetails(CarShowroom carShowRoomInstance)
        {
            Console.WriteLine($"Welcome to {carShowRoomInstance.CarShowRoomName}" +
                              $"\nLocation : {carShowRoomInstance.CarShowRoomAddress}" +
                              $"\nOwner : {carShowRoomInstance.CarShowRoomOwnerName}");

            Console.WriteLine($"+++++++++Car Catalogue++++++++");
            foreach (Car car in carShowRoomInstance.CarListInShowRoom)
            {
                Console.WriteLine($"\nCar Model Name : {car.CarModelName}" +
                                  $"\nCar Company Name : {car.CarCompanyName}" +
                                  $"\nNumber of Seater : {car.NumberOfSeaters} seater" +
                                  $"\nType of Car : {car.CarType}" +
                                  $"\nPrice of Car : Rs.{car.PriceOfCar}/-");
            }
        }
Exemplo n.º 22
0
        public void TestCountryAndModel()//тестирует правильность работы метода FillTestData;
        {
            CarShowroom1 = new CarShowroom();
            int n = 50;

            CarShowroom1.FillTestData(n);
            Assert.AreEqual(CarShowroom1.mar.Length, CarShowroom1.coun.Length);
            if (n > CarShowroom1.mar.Length * 2 + 1)
            {
                n = CarShowroom1.mar.Length * 2 + 1;
            }
            for (int i = 0; i < n; i++)
            {
                Assert.AreEqual(CarShowroom1.mar[i % CarShowroom1.coun.Length], CarShowroom1.Cars[i].Model);
                Assert.AreEqual(CarShowroom1.coun[i % CarShowroom1.mar.Length], CarShowroom1.Cars[i].ProdCountry);
            }
        }
Exemplo n.º 23
0
        public async void DeleteCarShowroom(int carshowroomId)
        {
            Task <CarShowroom> carShowroomTask = GetCarShowroom(carshowroomId);
            CarShowroom        carShowroom     = await carShowroomTask;

            if (carShowroom != null)
            {
                using (HttpResponseMessage response = await ApiHelper.ApiClient.DeleteAsync("api/CarShowrooms/" + carshowroomId))
                {
                    if (response.IsSuccessStatusCode)
                    {
                    }
                    else
                    {
                        throw new Exception(response.ReasonPhrase);
                    }
                }
            }
        }
Exemplo n.º 24
0
        public void SimilarOptionsInStockTest_Exception(string missingBrand, string wayToCatalog, string wayToStock)
        {
            CarShowroom salon = new CarShowroom(wayToCatalog, wayToStock);

            salon.ReadJsonFile();
            Invoker        newInvoker = new Invoker();
            ProspectiveCar wantedCar  = new ProspectiveCar();

            wantedCar.mark             = missingBrand;
            wantedCar.model            = "";
            wantedCar.typeOfBody       = "";
            wantedCar.transmissionType = "";
            wantedCar.engineType       = "";
            wantedCar.volume           = "";
            wantedCar.power            = "";
            wantedCar.climateControl   = "";
            wantedCar.salonType        = "";
            newInvoker.SetCommand(new SimilarOptionsInStock(salon, wantedCar));
            Assert.Throws <ArgumentOutOfRangeException>
            (
                () => newInvoker.Execute()
            );
        }
Exemplo n.º 25
0
        public async Task <IActionResult> PutCarShowroom(int id, CarShowroom carShowroom)
        {
            if (id != carShowroom.CarShowroomId)
            {
                return(BadRequest());
            }

            _context.Entry(carShowroom).State = EntityState.Modified;

            try
            {
                if (!_context.CarShowroomContainers.Where(c => c.CarShowroomContainerId == carShowroom.CarShowroomContainerId).Any())
                {
                    throw new Exception("Wrong CarShowroomContainer Id was selected.");
                }
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarShowroomExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                // ignore
                return(Ok());
            }

            return(NoContent());
        }
Exemplo n.º 26
0
 public login()
 {
     InitializeComponent();
     carShowroom1 = new CarShowroom();
 }
Exemplo n.º 27
0
Arquivo: Dao.cs Projeto: Kirill-27/OOP
 public Dao(CarShowroom carShowroom)
 {
     this.carShowroom = carShowroom;
 }
Exemplo n.º 28
0
 public MainPage()
 {
     InitializeComponent();
     carShowroom1 = new CarShowroom();
 }