public async Task <IActionResult> PutTires(int id, Tires tires)
        {
            if (id != tires?.TiresId)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TiresExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <Tires> > PostTires(Tires tires)
        {
            _context.Tires.Add(tires);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTires", new { id = tires?.TiresId }, tires));
        }
예제 #3
0
 private void ChangeSelectedTires()
 {
     selectedTires     = tires[selectedTiresIndex];
     raceStarter.tires = selectedTires;
     nameText.text     = selectedTires.name;
     tiresChanged.Raise();
 }
예제 #4
0
파일: Car.cs 프로젝트: LinleyYT/SoftUni
 public Car(string model, Engine engine, Cargo weight, Tires tireSpecs)
 {
     this.Model     = model;
     this.Engine    = engine;
     this.Cargo     = weight;
     this.TireSpecs = tireSpecs;
 }
예제 #5
0
 public Car(string model, string engine, float price) : base(model, engine, price)
 {
     _vehicleType = VehicleType.Car;
     Color        = new Color("White", 150.00f);
     Tires        = new Tires("Original", 4, 46.00f);
     Accessories  = new List <Accessories>();
 }
    private Tires tires;   //tirePressure,  tireAge

    public Car(string model, Engine engine, Cargo cargo, Tires tire)
    {
        Model  = model;
        Engine = engine;
        Cargo  = cargo;
        Tires  = tire;
    }
예제 #7
0
        public Tires getLast()
        {
            try
            {
                // open the connection:
                dbContext.sqlite_conn.Open();

                // create a new SQL command:
                dbContext.sqlite_cmd = dbContext.sqlite_conn.CreateCommand();

                // Let the SQLiteCommand object know our SQL-Query:
                dbContext.sqlite_cmd.CommandText = "SELECT * FROM " + this.tableName + " ORDER BY id DESC LIMIT 1";

                dbContext.sqlite_cmd.ExecuteNonQuery();

                model = model.DeserializeOne(serialize.SerializeResult(dbContext.sqlite_cmd.ExecuteReader()));

                // We are ready, now lets cleanup and close our connection:
                dbContext.sqlite_conn.Close();

                return(model);
            }
            catch (Exception ex)
            {
                Logging.LogWrite(ex.Message);
                throw ex;
            }
        }
예제 #8
0
 public Car(string model, Engine engine, Cargo cargo, Tires tires)
 {
     this.Model  = model;
     this.Engine = engine;
     this.Cargo  = cargo;
     this.Tires  = tires;
 }
예제 #9
0
        public Tires spendTire(Tires model)
        {
            try
            {
                DateTime now = new DateTime();
                now = DateTime.Now;
                // open the connection:
                dbContext.sqlite_conn.Open();

                // create a new SQL command:
                dbContext.sqlite_cmd = dbContext.sqlite_conn.CreateCommand();

                dbContext.sqlite_cmd.CommandText = "UPDATE " + this.tableName
                                                   + " SET " +
                                                   "date_release='" + model.date_release + "' " +
                                                   "where id=" + model.id + ";";

                dbContext.sqlite_cmd.ExecuteNonQuery();

                // We are ready, now lets cleanup and close our connection:
                dbContext.sqlite_conn.Close();

                return(model);
            }
            catch (Exception ex)
            {
                Logging.LogWrite(ex.Message);
                throw ex;
            }
        }
예제 #10
0
        protected bool fillTreadForms(Tires model)
        {
            nUDQuantity.Value = model.treads.Count;
            int i = 1;

            foreach (Treads tread in model.treads)
            {
                var numeric = FindByName("nUDtire" + i);
                if (numeric.GetType().ToString() == "System.Windows.Forms.NumericUpDown")
                {
                    NumericUpDown nup = numeric as NumericUpDown;
                    nup.Visible = true;
                    nup.Value   = Convert.ToDecimal(tread.tread);
                }
                var label = FindByName("lTire" + i);
                if (label.GetType().ToString() == "System.Windows.Forms.Label")
                {
                    Label l = label as Label;
                    l.Visible = true;
                }

                i++;
            }
            return(true);
        }
예제 #11
0
 public Bus(string model, string engine, float price, int numOfTiresr) : base(model, engine, price)
 {
     _vehicleType = VehicleType.Bus;
     Color        = new Color("White", 350.00f);
     Tires        = new Tires("Original", numOfTiresr, 102.00f);
     Accessories  = new List <Accessories>();
 }
예제 #12
0
 public Car(string model, Cargo cargo, Engine engine, Tires tires)
 {
     this.model  = model;
     this.cargo  = cargo;
     this.engine = engine;
     this.tires  = tires;
 }
예제 #13
0
        public Tires setNewTire(Tires model)
        {
            try
            {
                DateTime now = new DateTime();
                now = DateTime.Now;
                // open the connection:
                dbContext.sqlite_conn.Open();

                // create a new SQL command:
                dbContext.sqlite_cmd = dbContext.sqlite_conn.CreateCommand();

                dbContext.sqlite_cmd.CommandText = "" +
                                                   "INSERT INTO '" + this.tableName + "' (" +
                                                   "manufacturer," +
                                                   "size," +
                                                   "season_id," +
                                                   "rims_id," +
                                                   "quantity," +
                                                   "client_id," +
                                                   "comments," +
                                                   "date_creation," +
                                                   "date_release) " +
                                                   "VALUES ('" +
                                                   model.manufacturer +
                                                   "', '" + model.size +
                                                   "','" + model.season_id +
                                                   "','" + model.rims_id +
                                                   "','" + model.quantity +
                                                   "','" + model.client_id +
                                                   "','" + model.comments +
                                                   "','" + now.ToString("yyyy-MM-dd HH:mm:ss") +
                                                   "','" + model.date_release +
                                                   "');";

                dbContext.sqlite_cmd.ExecuteNonQuery();

                // We are ready, now lets cleanup and close our connection:
                dbContext.sqlite_conn.Close();

                int id = getLast().id;

                if (model.treads != null)
                {
                    TreadRepository treadRepo = new TreadRepository();
                    foreach (Treads t in model.treads)
                    {
                        treadRepo.setNewTread(t, id);
                    }
                }

                return(model);
            }
            catch (Exception ex)
            {
                Logging.LogWrite(ex.Message);
                throw ex;
            }
        }
예제 #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tires tires = db.Round.Find(id);

            db.Round.Remove(tires);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #15
0
 public Rims(Tires tires)
 {
     this.Tires          = tires;
     this.Name           = tires.Inches + " inch Rims";
     this.ProductionTime = tires.ProductionTime;
     this.Price          = tires.Price;
     this.Description    = "These rims perfectly fit " + tires.Inches + " inch tires and give it a finished look.";
 }
예제 #16
0
 public ActionResult Edit([Bind(Include = "TiresID,TireWidth,Sidewall,RimDiameter,MSRP,Manufacturer")] Tires tires)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tires).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tires));
 }
예제 #17
0
        public ActionResult Create([Bind(Include = "TiresID,TireWidth,Sidewall,RimDiameter,MSRP,Manufacturer")] Tires tires)
        {
            if (ModelState.IsValid)
            {
                db.Round.Add(tires);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tires));
        }
예제 #18
0
        static void Main(string[] args)
        {
            var log = new ConsoleLog();

            var tires = new Tires(log);

            var engine = new Engine(tires, log);

            var car = new Car(engine, log);

            car.Go();
        }
예제 #19
0
        public float GetPrice()
        {
            var price = _price + Color.ColorPrice;

            price += Tires.GetPrice();

            foreach (var item in Accessories)
            {
                price += (float)item;
            }
            return(price);
        }
예제 #20
0
    static void Main()
    {
        int        n    = int.Parse(Console.ReadLine());
        List <Car> cars = new List <Car>();

        for (int i = 0; i < n; i++)
        {
            string[] input = Console.ReadLine()
                             .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                             .ToArray();

            string model  = input[0];
            Engine engine = new Engine(int.Parse(input[1]), int.Parse(input[2]));
            Cargo  cargo  = new Cargo(int.Parse(input[3]), input[4]);
            Tires  tire   = new Tires();

            int startIndex = 5;
            for (int tires = 1; tires <= 6; tires++)
            {
                if (tires % 2 == 0)
                {
                    tire.Ages.Add(int.Parse(input[startIndex]));
                }
                else
                {
                    tire.Pressures.Add(double.Parse(input[startIndex]));
                }
                startIndex++;
            }
            Car car = new Car(model, engine, cargo, tire);
            cars.Add(car);
        }

        string cargoType = Console.ReadLine();

        switch (cargoType)
        {
        case "fragile":
            foreach (var c in cars.Where(x => x.Cargo.Type == "fragile" && x.Tires.Pressures.Any(y => y < 1)))
            {
                Console.WriteLine(c.Model);
            }
            break;

        case "flamable":
            foreach (var c in cars.Where(x => x.Cargo.Type == "flamable" && x.Engine.Power > 250))
            {
                Console.WriteLine(c.Model);
            }
            break;
        }
    }
예제 #21
0
 /// <summary>
 /// Wypełnienie formularza dla edycji
 /// </summary>
 /// <param name="model"></param>
 private void fillForm(Tires model)
 {
     tBManufacturer.Text     = model.manufacturer;
     nUDQuantity.Value       = model.quantity;
     cBRims.SelectedValue    = model.rims_id;
     tBsize.Text             = model.size;
     cBSeason.SelectedValue  = model.season_id;
     tBComment.Text          = model.comments;
     cBClients.SelectedValue = model.client_id;
     fillTreadForms(model);
     btnAddTire.Text = "Zapisz";
     this.Text       = "Edycja";
 }
예제 #22
0
 public AddTire(Form1 form, Tires model = null)
 {
     InitializeComponent();
     loadComboSeasons();
     loadClients();
     loadComboRims();
     if (model != null)
     {
         isNew = false;
         fillForm(model);
         tiresModel = model;
     }
     mainForm = form;
 }
예제 #23
0
        // GET: Tires/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tires tires = db.Round.Find(id);

            if (tires == null)
            {
                return(HttpNotFound());
            }
            return(View(tires));
        }
예제 #24
0
        public Tires updateTire(Tires model)
        {
            try
            {
                DateTime now = new DateTime();
                now = DateTime.Now;
                // open the connection:
                dbContext.sqlite_conn.Open();

                // create a new SQL command:
                dbContext.sqlite_cmd = dbContext.sqlite_conn.CreateCommand();

                dbContext.sqlite_cmd.CommandText = "UPDATE " + this.tableName
                                                   + " SET " +
                                                   "manufacturer='" + model.manufacturer + "'," +
                                                   "size='" + model.size + "'," +
                                                   "season_id='" + model.season_id + "'," +
                                                   "rims_id='" + model.rims_id + "'," +
                                                   "quantity='" + model.quantity + "'," +
                                                   "client_id='" + model.client_id + "'," +
                                                   "comments='" + model.comments + "' " +
                                                   //"date_creation='" + model.date_creation + "'," +
                                                   //"date_release='" + model.date_release + "' " +
                                                   "where id=" + model.id + ";";

                dbContext.sqlite_cmd.ExecuteNonQuery();

                // We are ready, now lets cleanup and close our connection:
                dbContext.sqlite_conn.Close();

                if (model.treads != null)
                {
                    TreadRepository treadRepo = new TreadRepository();
                    treadRepo.deleteTread(model.id);
                    foreach (Treads t in model.treads)
                    {
                        treadRepo.setNewTread(t, model.id);
                    }
                }

                return(model);
            }
            catch (Exception ex)
            {
                Logging.LogWrite(ex.Message);
                throw ex;
            }
        }
예제 #25
0
        public static CarModel CreateCarModel()
        {
            CarModel m = new CarModel();
            Tires    t = new Tires(Inches.Sixteen);

            m.AddPart(new Cabrio());
            m.AddPart(new AirSuspension());
            m.AddPart(new DieselEngine());
            m.AddPart(new Accumulator(AccumulatorSize.Average));
            m.AddPart(new ManualTransmission());
            m.AddPart(new LeatherInterior());
            m.AddPart(t);
            m.AddPart(new Rims(t));
            m.AddPart(new GPS());
            return(m);
        }
        public string spendPdf(Tires model)
        {
            string physicPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            string htmlPath   = physicPath + "\\documentTemplates\\spend.html";

            StreamReader sr   = new StreamReader(htmlPath);
            string       html = sr.ReadToEnd();

            html = html.Replace("[client_full_name]", model.client.full_name);
            html = html.Replace("[client_email]", model.client.email);
            html = html.Replace("[client_phone]", model.client.phone);
            html = html.Replace("[create_date]", model.date_creation);
            html = html.Replace("[spend_date]", model.date_release);

            return(html);
        }
예제 #27
0
파일: Program.cs 프로젝트: Andriy68/Andriy
        static void Main()
        {
            List <Car> cars = new List <Car>();

            Console.Write("Input the kilkist of cars: ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                double tirePreasure_1, tirePreasure_2, tirePreasure_3, tirePreasure_4;
                string model, cargoType, allInput;
                int    engineSpeed, enginePower, cargoWeight, tireAge_1, tireAge_2, tireAge_3, tireAge_4;
                Console.WriteLine($"Input Car № {i + 1}");
                allInput = Console.ReadLine();
                string[] allValues = allInput.Split(" ");
                model          = allValues[0];
                engineSpeed    = int.Parse(allValues[1]);
                enginePower    = int.Parse(allValues[2]);
                cargoWeight    = int.Parse(allValues[3]);
                cargoType      = allValues[4];
                tirePreasure_1 = double.Parse(allValues[5]);
                tireAge_1      = int.Parse(allValues[6]);
                tirePreasure_2 = double.Parse(allValues[7]);
                tireAge_2      = int.Parse(allValues[8]);
                tirePreasure_3 = double.Parse(allValues[9]);
                tireAge_3      = int.Parse(allValues[10]);
                tirePreasure_4 = double.Parse(allValues[11]);
                tireAge_4      = int.Parse(allValues[12]);
                Engine engine  = new Engine(engineSpeed, enginePower);
                Go     cargo   = new Go(cargoWeight, cargoType);
                Tires  tires   = new Tires(tireAge_1, tirePreasure_1, tireAge_2, tirePreasure_2, tireAge_3, tirePreasure_3, tireAge_4, tirePreasure_4);
                Car    tempcar = new Car(model, engine, cargo, tires);
                cars.Add(tempcar);
            }

            string cmd = Console.ReadLine();

            if (cmd == "fragile")
            {
                PrintFr(cars);
            }
            else if (cmd == "flamable")
            {
                PrintFl(cars);
            }
        }
예제 #28
0
        static void Main()
        {
            var auto1 = new BMW();
            var auto2 = new AUDI();

            PrintAuto(auto1);
            PrintAuto(auto2);
            Console.WriteLine("----------------------------------");

            var auto3 = new Insurance(new BMW());
            var auto4 = new Conditioner(new Tires(new AUDI()));
            var auto5 = new Tires(new Conditioner(new Insurance(new BMW())));

            PrintAuto(auto3);
            PrintAuto(auto4);
            PrintAuto(auto5);
        }
예제 #29
0
 private void spendFromStock(Tires model)
 {
     try
     {
         DateTime now = DateTime.Now;
         model.date_release = now.ToString("yyyy-MM-dd HH:mm:ss");
         model.client       = model.getClient(model.client_id);
         documentHelper documentH = new documentHelper();
         string         html      = documentH.spendPdf(model);
         var            result    = pdfHelper.PdfSharpConvert(html, "wydania", "wydnaie", "pdf");
         db.spendTire(model);
     }
     catch (Exception ex)
     {
         Logging.LogWrite(ex.Message);
         MessageBox.Show("Wystąpił nieoczekiwany wyjątek. \r\n" + ex.Message);
     }
 }
예제 #30
0
        /// <summary>
        /// Ładowanie modelu w celu edycji
        /// </summary>
        /// <returns></returns>
        private Tires loadTireModel()
        {
            Tires model = new Tires();

            model.manufacturer = tBManufacturer.Text;
            model.quantity     = Convert.ToInt32(nUDQuantity.Value);
            model.rims_id      = (int)cBRims.SelectedValue;
            model.size         = tBsize.Text;
            model.season_id    = (int)cBSeason.SelectedValue;
            model.comments     = tBComment.Text;
            model.client_id    = (cBClients.SelectedValue != null ? (int)cBClients.SelectedValue : 0);
            model.treads       = getTreadsFromForm();
            if (tiresModel != null)
            {
                model.id = tiresModel.id;
            }

            return(model);
        }