コード例 #1
0
        public IActionResult UpdateRssFeed(int id, [FromBody] RssFeedDomainObj feedToBeUpdated)
        {
            if (feedToBeUpdated == null)
            {
                return(BadRequest());
            }

            if (feedToBeUpdated.Description == feedToBeUpdated.Source)
            {
                ModelState.AddModelError("Description", "The provided description should be different from the Source.");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!_rssFeedService.FeedExists(id))
            {
                return(NotFound());
            }
            var feedToBeUpdatedDto = Mapper.Map <RssFeedDto>(feedToBeUpdated);

            _rssFeedService.UpdateRssFeed(id, feedToBeUpdatedDto);
            return(NoContent());
        }