partial void DeleteQuestionnaireDetail(QuestionnaireDetail instance);
 partial void InsertQuestionnaireDetail(QuestionnaireDetail instance);
 partial void UpdateQuestionnaireDetail(QuestionnaireDetail instance);
        public int Insert(QuestionnaireModelShow item)
        {
            s26webDataContext db = new s26webDataContext();
            try
            {
                QuestionnaireMain new_item = new QuestionnaireMain
                {
                    UserId = item.VolunteersId,
                    CategoryId = item.CategoryId,
                    SubmitTime = DateTime.UtcNow
                };
                db.QuestionnaireMain.InsertOnSubmit(new_item);
                db.SubmitChanges();

                for (int i = 1; i < 9; i++)
                {
                    string Answer = "";
                    switch (i)
                    {
                        case 1:
                            Answer = item.Q1;
                            break;
                        case 2:
                            Answer = item.Q2;
                            break;
                        case 3:
                            Answer = item.Q3;
                            break;
                        case 4:
                            Answer = item.Q4;
                            break;
                        case 5:
                            Answer = item.Q5;
                            break;
                        case 6:
                            Answer = item.Q6;
                            break;
                        case 7:
                            Answer = item.Q7;
                            break;
                        case 8:
                            Answer = item.Q8;
                            break;
                    }
                    QuestionnaireDetail new_item2 = new QuestionnaireDetail
                    {

                        MainId = db.QuestionnaireMain.OrderByDescending(o => o.Id).FirstOrDefault(f => f.Id != null).Id,
                        QuestionId = @i,
                        UserAnswer = Answer
                    };
                    db.QuestionnaireDetail.InsertOnSubmit(new_item2);
                }

                db.SubmitChanges();
                db.Connection.Close();
                return new_item.Id;
            }
            catch
            {
                return -1;
            }
        }