public async Task <IActionResult> PutCountryCode([FromRoute] int id, [FromBody] CountryCode countryCode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(countryCode).State = EntityState.Modified;

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

            return(NoContent());
        }
        public async Task <IActionResult> PutComment(Comment comment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(comment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CommentExists(comment.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        public void DeleteReleaseNote(ReleaseNote releaseNote)
        {
            using (var db = new ReleaseNotesContext())
            {
                db.Entry(new ReleaseNote {
                    Version = releaseNote.Version
                }).State = EntityState.Deleted;

                db.SaveChanges();
            }
        }