Beispiel #1
0
        public IActionResult Create(TopicModel model)
        {
            if (ModelState.IsValid)
            {
                //Get Currently Logged In User Id
                model.AuthorId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

                var createTopic = _topic.Create(model);
                if (createTopic.Succeeded)
                {
                    return(RedirectToAction("index"));
                }
                else
                {
                    ModelState.AddModelError("ServerError", createTopic.Message);
                }
            }
            return(View(model));
        }