public async Task <IHttpActionResult> PutCarApplication(int id, CarApplication carApplication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carApplication.Id)
            {
                return(BadRequest());
            }

            db.Entry(carApplication).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetCarApplication(int id)
        {
            CarApplication carApplication = await db.Applications.FindAsync(id);

            if (carApplication == null)
            {
                return(NotFound());
            }

            return(Ok(carApplication));
        }
        public async Task <IHttpActionResult> PostCarApplication(CarApplication carApplication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Applications.Add(carApplication);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = carApplication.Id }, carApplication));
        }
        public async Task <IHttpActionResult> DeleteCarApplication(int id)
        {
            CarApplication carApplication = await db.Applications.FindAsync(id);

            if (carApplication == null)
            {
                return(NotFound());
            }

            db.Applications.Remove(carApplication);
            await db.SaveChangesAsync();

            return(Ok(carApplication));
        }
Esempio n. 5
0
    public IEnumerator Engine(Path path)
    {
        while (true)
        {
            yield return(new WaitForSeconds(Random.Range(2, path.wave)));

            if (path.cars.Count < path.maximumCarIsWaiting)
            {
                CarApplication c = Instantiate(Resources.Load <CarApplication>("Car"));
                c.model.id   = Random.Range(0, 99);
                c.model.path = path;
                c.model.flag = path.flag;

                path.cars.Add(c.model.id);
            }
        }
    }