Пример #1
0
        public IActionResult Add(Topic topic, int id)
        {
            Topic nt = new Topic
            {
                Subject = topic.Subject,
                Content = topic.Content,
                ForumId = id,
                time    = DateTime.Now
            };

            topicServices.AddTopic(nt);
            return(RedirectToAction("List", new { Id = id }));
        }
Пример #2
0
        public async Task <IActionResult> CreateTopic([FromBody] TopicUpsertion topicUpsertion)
        {
            try
            {
                var isAuthenticated = User.Identity.IsAuthenticated;

                if (isAuthenticated)
                {
                    var currentLoggedUser = User.Identity.Name;
                    return(Ok(await _topicServices.AddTopic(topicUpsertion, currentLoggedUser)));
                }
                else
                {
                    return(BadRequest("Please Login!!"));
                }
            }
            catch (LoginException ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }