Esempio n. 1
0
 [HttpPut]      //Dịch vụ PUT
 public bool UpdateDA(int id, char da)
 {
     try
     {
         DBGameDataContext db = new DBGameDataContext();
         //lấy user trong database ra
         DAPAN dapan = db.DAPANs.FirstOrDefault(x => x.IDCH == id);
         if (dapan == null)
         {
             return(false);              //không tồn tại false
         }
         dapan.DapAn1 = da;
         db.SubmitChanges();//xác nhận chỉnh sửa
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        private CAUHOI Add_quiz_to_db(int idLinhVuc,
                                      int idLoaiCauHoi,
                                      string noiDungCauHoi,
                                      List <string> noiDungDapAns,
                                      List <bool> tinhChats,
                                      List <int> thuTus)
        {
            CAUHOI cauhoi = new CAUHOI();

            cauhoi = cauhoi.Add_cau_hoi(noiDungCauHoi, idLinhVuc, idLoaiCauHoi);
            for (int idx = 0; idx < noiDungDapAns.Count; idx++)
            {
                string noiDungDapAn = noiDungDapAns[idx];
                bool   tinhChat     = tinhChats[idx];
                int    thuTu        = thuTus[idx];
                int    idCauHoi     = cauhoi.IDCauHoi;
                DAPAN  dapan        = new DAPAN();
                dapan.Add_dap_an(noiDungDapAn, idCauHoi, tinhChat, thuTu);
            }
            return(cauhoi);
        }