public ActionResult GoToEdit(string QuizId)
        {
            int userId = (int)Session["UserId"];
            MakeQuizModel model = new MakeQuizModel();
            int qId = int.Parse(QuizId);

            model.QuizId = qId;

            //選択されたクイズデータをモデルへ
            using (var db = new SakanaDBEntities1())
            {
                model = (from q in db.QUIZ
                        where q.USER_ID == userId
                        && q.DELETE_FLG == 0
                        && q.QUIZ_ID==qId
                        select new MakeQuizModel()
                        {
                            QuizName = q.QUIZ_NAME,
                            QuizDetail =q.QUIZ_DETAIL,
                            CategoryId = (int)q.CATEGORY_ID,
                            Answer = q.ANSWER,
                            AnswerHiragana = q.ANSWER_HIRAGANA,
                            AnswerDetail=q.ANSWER_DETAIL,
                        }).First();

            }
            model.HintList = GetHints(qId);

            //カテゴリリストの項目取得
            model.CategoryList = MakeCategoryList();

            //画像リストの項目取得
            //model.PictList = MakePictList();

            return View("MakeQuiz", model);
        }
        public ActionResult MakeQuiz(MakeQuizModel postedModel)
        {
            if (!ModelState.IsValid)
            {
                //validに引っかかったら元の画面へ

                //カテゴリリストの項目取得
                postedModel.CategoryList = MakeCategoryList();

                //画像リストの項目取得
                //postedModel.PictList = MakePictList();
                return View(postedModel);
            }

            //クイズ登録
            RegisterQuiz(postedModel);
            return Redirect("MadeQuizList");
        }
        /// <summary>
        /// クイズ登録
        /// </summary>
        /// <param name="postedModel"></param>
        private void RegisterQuiz(MakeQuizModel postedModel)
        {
            using (var db = new SakanaDBEntities1())
            {
                //新規登録
                if (postedModel.QuizId == null)
                {
                    //クイズテーブルへのインサート
                    var inserted = db.QUIZ.Add(new QUIZ()
                    {
                        QUIZ_NAME = postedModel.QuizName,
                        QUIZ_DETAIL = postedModel.QuizDetail,
                        USER_ID = (int)Session["UserId"],
                        CHALLENGE_NUM = 0,
                        CLEAR_NUM = 0,
                        CATEGORY_ID = postedModel.CategoryId,
                        ANSWER = postedModel.Answer,
                        ANSWER_HIRAGANA = postedModel.AnswerHiragana,
                        ANSWER_DETAIL = postedModel.AnswerDetail,
                        CREATED_DT = DateTime.Now,
                        EDITED_DT = DateTime.Now,
                        DELETE_FLG = 0
                    });

                    //クイズ画像テーブルへのインサート
                    int i = 1;
                    foreach (var hint in postedModel.HintList)
                    {

                        db.QUIZ_PICT.Add(new QUIZ_PICT()
                        {
                            QUIZ_ID = inserted.QUIZ_ID,
                            HINT_SEQ = i,
                            PICT_ID = hint.PictId,
                            HINT_TXT = hint.HintTxt
                        });

                        i++;
                    }
                }
                //編集
                else
                {
                    //クイズテーブル更新
                    var targetQUIZ = db.QUIZ.Single(q => q.QUIZ_ID==postedModel.QuizId);
                    targetQUIZ.QUIZ_NAME = postedModel.QuizName;
                    targetQUIZ.QUIZ_DETAIL = postedModel.QuizName;
                    targetQUIZ.CATEGORY_ID = postedModel.CategoryId;
                    targetQUIZ.ANSWER = postedModel.Answer;
                    targetQUIZ.ANSWER_HIRAGANA = postedModel.AnswerHiragana;
                    targetQUIZ.ANSWER_DETAIL = postedModel.AnswerDetail;
                    targetQUIZ.EDITED_DT = DateTime.Now;

                    //クイズ画像テーブル更新
                    int i = 1;
                    foreach (var hint in postedModel.HintList)
                    {
                        var targetQUIZPIC = db.QUIZ_PICT.Single
                                               (q => q.QUIZ_ID == postedModel.QuizId
                                               && q.HINT_SEQ==i);
                        targetQUIZPIC.PICT_ID= hint.PictId;
                        targetQUIZPIC.HINT_TXT = hint.HintTxt;

                        i++;
                    }
                }
                db.SaveChanges();
            }
        }
        public ActionResult MakeQuiz()
        {
            MakeQuizModel model = new MakeQuizModel();

            //カテゴリリストの項目取得
            model.CategoryList = MakeCategoryList();

            //画像リストの項目取得
            //model.PictList = MakePictList();
            model.Picts = SearchPictData();

            return View("MakeQuiz",model);
        }