Exemple #1
0
        public async Task <IHttpActionResult> PostDPF(DPF dPF)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DPF.Add(dPF);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (DPFExists(dPF.id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = dPF.id }, dPF));
        }
Exemple #2
0
        public async Task <IHttpActionResult> PutDPF(int id, DPF dPF)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public async Task <IHttpActionResult> GetDPF(int id)
        {
            DPF dPF = await db.DPF.FindAsync(id);

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

            return(Ok(dPF));
        }
Exemple #4
0
        public async Task <IHttpActionResult> DeleteDPF(int id)
        {
            DPF dPF = await db.DPF.FindAsync(id);

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

            db.DPF.Remove(dPF);
            await db.SaveChangesAsync();

            return(Ok(dPF));
        }