コード例 #1
0
        public async Task <ActionResult> Details(ArticleAndReplyModel replyModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string subject = TempData["subject"].ToString();
                    replyModel.reply.ArticleID    = db.MainArticles.Where(u => u.ID.ToString().Equals(subject)).Single().ID;
                    replyModel.reply.ArticelMaker = db.MainArticles.Where(u => u.ID.Equals(replyModel.reply.ArticleID)).SingleOrDefault().CreateUser;
                    repository = new ReplyModelRepository(db);
                    await repository.Insert(replyModel);

                    return(RedirectToAction("Details", "MainArticleModels", new { id = replyModel.reply.ArticleID }));
                }
            }
            catch (DataException)
            {
                return(RedirectToAction("DataError", "Error", new { message = "用戶儲存錯誤" }));
            }
            return(View(replyModel));
        }
コード例 #2
0
 public ForumController()
 {
     this.repository = new ForumRepository(db);
 }
コード例 #3
0
 public MainArticleModelsController()
 {
     this.repository = new MainArticleModelRepository(db);
 }
コード例 #4
0
 public MainThemesController()
 {
     this.repository = new MainThemeRepository(db);
 }
コード例 #5
0
 public ReplyModelsController()
 {
     this.repository = new ReplyModelRepository(db);
 }