//cbGet and cbSort//

        //Buttons + attached logic//
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Car car = new Car();

            car.Color        = txtColor.Text;
            car.Manufacturer = txtManufacturer.Text;
            car.Model        = txtModel.Text;
            decimal.TryParse(txtPrice.Text, out decimal price);
            car.Price = price;
            int.TryParse(txtGears.Text, out int gears);
            car.TransmissionGears = gears;
            car.TransmissionType  = txtTransmission.Text;
            int.TryParse(txtEngine.Text, out int engineId);
            car.EngineId = engineId;
            int.TryParse(txtDealership.Text, out int dealershipId);
            car.CarDealershipId = dealershipId;
            if (txtOwner.Text != "")
            {
                int.TryParse(txtOwner.Text, out int ownerId);
                car.OwnerId = ownerId;
            }

            CarBusiness carBusiness = new CarBusiness();

            carBusiness.Add(car);
            PopulateDataGridViewDefault();
            ClearTextBoxes();
        }
Example #2
0
        CarBusiness GenerateBusiness(int index)
        {
            var cb = new CarBusiness();

            cb.Name  = "Car_" + index.ToString();
            cb.Month = m_month;

            var count = m_rand.Next(1, 10);

            int start = 1;
            int end   = 1;

            var dayCount = m_month.DayCount + 1;

            for (int i = 0; i < count && end < dayCount; i++)
            {
                var b = new Leasing();
                b.Title        = "bussy_" + i.ToString();
                start          = m_rand.Next(end, dayCount);
                b.DateStart    = new DateTime(m_month.Year, m_month.Index, start);
                end            = m_rand.Next(start, dayCount);
                b.DateEnd      = new DateTime(m_month.Year, m_month.Index, end);
                b.CurrentMonth = m_month;
                cb.Add(b);
                end++;
            }

            return(cb);
        }
        public void AddCar()
        {
            var mockSet = new Mock <DbSet <Car> >();

            var mockContext = new Mock <CarDealershipContext>();

            mockContext.Setup(m => m.Cars).Returns(mockSet.Object);

            var service = new CarBusiness(mockContext.Object);

            service.Add(new Car());

            mockSet.Verify(m => m.Add(It.IsAny <Car>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
Example #4
0
        static CarBusiness GenerateBusiness(int index, Month start, Month end)
        {
            var cb = new CarBusiness();

            cb.Name = "Car_" + index.ToString();
            //start = new Month(start.Year, m_rand.Next(start.Index, end.Index + 1));
            //end = new Month(end.Year, m_rand.Next(start.Index, end.Index + 1));
            cb.Monthes = Month.GetMonthes(start, end);

            var count = m_rand.Next(1, 10);

            int startDayI  = 1;
            var dayCount   = Month.GetDaysCount(start, end);
            int endDayI    = end.DayCount;
            int monthIndex = 0;

            var blockedFlag = m_rand.Next(1, 25);
            var addBlocked  = App.SearchSettings.IncludeBlocked;

            for (int mi = start.Index; mi <= end.Index; mi++)
            {
                monthIndex = mi;

                for (int i = 0; i < count && endDayI <= end.DayCount; i++)
                {
                    var b = new Leasing();
                    b.Title     = "bussy_" + i.ToString();
                    startDayI   = m_rand.Next(startDayI, endDayI);
                    b.DateStart = new DateTime(start.Year, monthIndex, startDayI);
                    endDayI     = m_rand.Next(startDayI, dayCount);
                    //b.DateEnd = new DateTime(end.Year, end.Index, end.DayCount <= endI ? endI : end);
                    b.Monthes = cb.Monthes;
                    b.CarName = cb.Name;
                    b.Saler   = "Saler_" + i.ToString();

                    if (addBlocked)
                    {
                        b.Blocked = blockedFlag == 23; //магическое число 23 (просто случайное число в пределах диапазона)
                    }
                    cb.Add(b);
                    endDayI++;
                }
            }

            return(cb);
        }
Example #5
0
        static CarBusiness GenerateBusiness(int index, Month month)
        {
            var cb = new CarBusiness();

            cb.Name  = "Car_" + index.ToString();
            cb.Month = month;

            var count = m_rand.Next(1, 10);

            int start = 1;
            int end   = 1;

            var dayCount = month.DayCount + 1;

            var blockedFlag = m_rand.Next(1, 25);
            var addBlocked  = App.SearchSettings.IncludeBlocked;

            for (int i = 0; i < count && end < dayCount; i++)
            {
                blockedFlag = m_rand.Next(1, 25);
                var b = new Leasing();
                b.Title        = "bussy_" + i.ToString();
                start          = m_rand.Next(end, dayCount);
                b.DateStart    = new DateTime(month.Year, month.Index, start);
                end            = m_rand.Next(start, dayCount);
                b.DateEnd      = new DateTime(month.Year, month.Index, end);
                b.CurrentMonth = month;
                b.CarName      = cb.Name;
                b.Saler        = "Saler_" + i.ToString();

                if (addBlocked)
                {
                    b.Blocked = blockedFlag == 23; //магическое число 23 (просто случайное число в пределах диапазона)
                }
                cb.Add(b);
                end++;
            }

            return(cb);
        }