Example #1
0
        public IHttpActionResult Create(FeedMetaDataDto feedMetaData)
        {
            var currentUser = Request.GetOwinContext().GetCurrentUser();

            var newFeed = new FeedMetaData(feedMetaData.FeedName, feedMetaData.Title, currentUser.UserName);

            //create
            newFeed = _genericRepository.Insert(newFeed);

            var feedDto = AutoMapper.Mapper.Map<FeedMetaDataDto>(newFeed);

            return Ok(feedDto);
        }
Example #2
0
        public async Task<ActionResult> Create(FeedMetaDataViewModel newFeedViewModel)
        {
            var exists = FeedMetaDataViewModels.Any(x => x.FeedName == newFeedViewModel.FeedName);
            try
            {
                if (ModelState.IsValid && !exists)
                {
                    var parameter = new FeedMetaDataDto()
                    {
                        FeedName = newFeedViewModel.FeedName,
                        Title = newFeedViewModel.Title
                    };
                    var newFeed = await WebApiService.Instance.PostAsync<FeedMetaDataDto>("/Feeds/Create", UserManager.User.AccessToken, parameter);

                    //create
                    var feedMetaDataViewModel = Mapper.Map<FeedMetaDataViewModel>(newFeed);
                    return RedirectToAction("Show", "Feed", feedMetaDataViewModel.GetRouteValues());
                }
            }
            catch (Exception ex)
            {
                Log.Error("Could not create feed", ex);
            }
            if (exists)
            {
                ModelState.AddModelError("FeedName", "feedname already exists!");
            }
            else
            {
                ModelState.AddModelError("", "Could not create feed");
            }

            return View(newFeedViewModel);
        }