public ActionResult CreateTopic([Bind(Include = "Title, TeamId, AuthorId")] TopicBindModel model) { if (this.ModelState.IsValid) { this.service.AddTopic(model); // TO DO redirect to my Topics return(this.RedirectToAction("MyTeams")); } else { return(this.RedirectToAction("CreateTopic", new { teamId = model.TeamId })); } }
public void AddTopic(TopicBindModel model) { var currentUser = this.GetCurrentUser(model.AuthorId); Topic topic = new Topic() { Title = model.Title, Author = currentUser, Team = this.Data.GetById(model.TeamId) }; this.topics.Add(topic); currentUser.Topics.Add(topic); this.topics.Save(); }