コード例 #1
0
 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 }));
     }
 }
コード例 #2
0
ファイル: TeamService.cs プロジェクト: Damyanski/Team-manager
        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();
        }