public async Task <ActionResult> Create(NewTopicModel model) { if (ModelState.IsValid) { var topic = new Topic { CategoryId = model.CategoryId, Name = model.Name, User = await _users.GetByEmailAsync(User.Identity.Name), IsClosed = false, }; var msg = new ForumMessage(model.InitialText, topic.Id, topic.User.Id); if (await _topics.CreateAsync(topic, msg, User.Identity.Name)) { return(Ok(topic)); } else { ModelState.AddModelError("", _topics.LastError); return(BadRequest(model)); } } return(BadRequest(model)); }