public async Task <IHttpActionResult> PutMarcaAutomovel(int id, MarcaAutomovel marcaAutomovel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetMarcaAutomovel(int id)
        {
            MarcaAutomovel marcaAutomovel = await db.MarcaAutomovels.FindAsync(id);

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

            return(Ok(marcaAutomovel));
        }
        public async Task <IHttpActionResult> PostMarcaAutomovel(MarcaAutomovel marcaAutomovel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MarcaAutomovels.Add(marcaAutomovel);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = marcaAutomovel.Id }, marcaAutomovel));
        }
        public async Task <IHttpActionResult> DeleteMarcaAutomovel(int id)
        {
            MarcaAutomovel marcaAutomovel = await db.MarcaAutomovels.FindAsync(id);

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

            db.MarcaAutomovels.Remove(marcaAutomovel);
            await db.SaveChangesAsync();

            return(Ok(marcaAutomovel));
        }