コード例 #1
0
        public async Task<IHttpActionResult> PutGalleryComment(int id, GalleryComment galleryComment)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        public async Task<IHttpActionResult> PostGalleryComment(GalleryComment galleryComment)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.GalleryComments.Add(galleryComment);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = galleryComment.GalleryCommentNo }, galleryComment);
        }