Esempio n. 1
0
        public async Task <ActionResult <myCar> > PostmyCar(myCar myCar)
        {
            _context.myCar.Add(myCar);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetmyCar", new { id = myCar.id }, myCar));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutmyCar(int id, myCar myCar)
        {
            if (id != myCar.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
    static void Main(string[] args)
    {
        myCar toyota = new myCar(89, "Red");

        // Console.WriteLine(toyota.getTopSpeed().ToString();
        toyota.paintCar("Green");
        Console.ReadKey();
    }
Esempio n. 4
0
        ///=======================================================
        ///

        public void SaveCarMethod()
        {
            MainDatabaseSourceDataContext dbContext = new MainDatabaseSourceDataContext();
            myCar car = new myCar();

            car.Name  = this.dataModel.myName;
            car.Desc1 = Int32.Parse(this.dataModel.myDesc1);
            car.Desc2 = this.dataModel.myDesc2.Date;
            car.Desc3 = this.dataModel.myDesc3;
            car.Desc4 = this.dataModel.myDesc4;
            dbContext.myCars.InsertOnSubmit(car);
            dbContext.SubmitChanges();
            MessageBox.Show("Saved Successfuly !");
            //---- Clear the object details after saving -----
            ClearObjectDetails();
        }