示例#1
0
        public IActionResult CreateFeed([FromBody] FeedDTO input)
        {
            if (ModelState.IsValid)
            {
                return(Ok(_feedService.AddFeed(input)));
            }

            return(BadRequest());
        }
        public async Task <IActionResult> CreateFeed(FeedDTO model)
        {
            var result = await _feedServices.AddFeed(model);

            if (result.Success)
            {
                return(Created("", result));
            }
            return(BadRequest(result));
        }
示例#3
0
        public ActionResult Create(FeedCreateViewModel feedViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(feedViewModel));
            }

            Feed newFeed;

            try
            {
                newFeed = Feed.CreateFeed(feedViewModel.Url);
            }
            catch (FeedDataLoadException ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(feedViewModel));
            }

            feedService.AddFeed(newFeed);

            return(RedirectToAction("Index"));
        }