Beispiel #1
0
        public async Task <IHttpActionResult> PutPatinete(int id, Patinete patinete)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> GetPatinete(int id)
        {
            Patinete patinete = await db.Patinetes.FindAsync(id);

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

            return(Ok(patinete));
        }
Beispiel #3
0
        public async Task <IHttpActionResult> PostPatinete(Patinete patinete)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Patinetes.Add(patinete);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = patinete.Id }, patinete));
        }
Beispiel #4
0
        public async Task <IHttpActionResult> DeletePatinete(int id)
        {
            Patinete patinete = await db.Patinetes.FindAsync(id);

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

            db.Patinetes.Remove(patinete);
            await db.SaveChangesAsync();

            return(Ok(patinete));
        }