Esempio n. 1
0
        public async Task <IHttpActionResult> Putschips(int id, schips schips)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != schips.NUMMER)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> Getschips(int id)
        {
            schips schips = await db.schip.FindAsync(id);

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

            return(Ok(schips));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> Deleteschips(int id)
        {
            schips schips = await db.schip.FindAsync(id);

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

            db.schip.Remove(schips);
            await db.SaveChangesAsync();

            return(Ok(schips));
        }
Esempio n. 4
0
        public async Task <IHttpActionResult> Postschips(schips schips)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                db.schip.Add(schips);
                await db.SaveChangesAsync();

                return(CreatedAtRoute("DefaultApi", new { id = schips.NUMMER }, schips));
            }
            catch (Exception e)
            {
                return(Ok(e));
            }
        }