コード例 #1
0
        public async Task <IHttpActionResult> PostinDesign(inDesign inDesign)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.inDesigns.Add(inDesign);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (inDesignExists(inDesign.JobID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = inDesign.JobID }, inDesign));
        }
コード例 #2
0
        public async Task <IHttpActionResult> PutinDesign(int id, inDesign inDesign)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public async Task <IHttpActionResult> GetinDesign(int id)
        {
            inDesign inDesign = await db.inDesigns.FindAsync(id);

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

            return(Ok(inDesign));
        }
コード例 #4
0
        public async Task <IHttpActionResult> DeleteinDesign(int id)
        {
            inDesign inDesign = await db.inDesigns.FindAsync(id);

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

            db.inDesigns.Remove(inDesign);
            await db.SaveChangesAsync();

            return(Ok(inDesign));
        }