Example #1
0
 public ActionResult Create(Post post)
 {
     try
     {
         // TODO: Add insert logic here
         forumRepository.AddPost(post);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(post));
     }
 }
Example #2
0
        public ActionResult Create(Post Post)
        {
            try
            {
                forumRepository.AddPost(Post);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View(Post));
            }
        }
Example #3
0
        public async Task AddPost(AddPostRequest request)
        {
            DateTime now  = DateTime.Now;
            Post     post = new Post()
            {
                ForumId = request.ForumId, Header = request.Header, Description = request.Description, CreatedDate = now
            };
            int postId = await _repository.AddPost(post);

            var tags = new List <Tag>();

            foreach (var tag in request.Tags)
            {
                var newTag = new Tag()
                {
                    PostId = postId, TagName = tag
                };
                tags.Add(newTag);
            }
            await _repository.AddTags(tags);
        }