public async Task <IActionResult> PutWinzelComment([FromRoute] long id, [FromBody] WinzelComment winzelComment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Beispiel #2
0
        private static WinzelComment BuildComment(string text, string date = "heute")
        {
            var comment = new WinzelComment();

            comment.Text = text;
            comment.Date = date;
            return(comment);
        }
        public async Task <IActionResult> PostWinzelComment([FromBody] WinzelComment winzelComment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.WinzelComments.Add(winzelComment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWinzelComment", new { id = winzelComment.Id }, winzelComment));
        }