Пример #1
0
        public async Task <IActionResult> PutFollowedPodcast([FromQuery] string rss, [FromBody] FollowedPodcast followedPodcast)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (rss != followedPodcast.Rss)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PostFollowedPodcast([FromBody] FollowedPodcast followedPodcast)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.FollowedPodcast.Add(followedPodcast);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFollowedPodcast", new { rss = followedPodcast.Rss }, followedPodcast));
        }