public bool updateQuestion(question updateQuest) { bool result = false; try { using (studentlearnEntities1 db = new studentlearnEntities1()) { var uQ = db.questions.Where(w => w.questionName == updateQuest.questionName).FirstOrDefault(); uQ.questionText = updateQuest.questionText; uQ.reply = updateQuest.reply; uQ.reply1 = updateQuest.reply1; uQ.reply2 = updateQuest.reply2; uQ.reply3 = updateQuest.reply3; uQ.reply4 = updateQuest.reply4; uQ.categoryID = updateQuest.categoryID; db.SaveChanges(); result = true; } } catch (Exception e) { MessageBox.Show("İşlem sırasında bir hata meydana geldi." + e); result = false; } return(result); }
public bool deleteQuestion(int qid) { bool result = false; try { using (studentlearnEntities1 db = new studentlearnEntities1()) { var deleteQuestion = db.questions.Where(w => w.id == qid).FirstOrDefault(); db.questions.Remove(deleteQuestion); db.SaveChanges(); result = true; } } catch (Exception e) { MessageBox.Show("İşlem sırasında bir hata meydana geldi." + e); result = false; } return(result); }
public bool addQuestion(question quest) { bool result = false; try { using (studentlearnEntities1 db = new studentlearnEntities1()) { db.questions.Add(quest); db.SaveChanges(); result = true; } } catch (Exception e) { MessageBox.Show("İşlem sırasında bir hata meydana geldi." + e); result = false; mainConnect(); } return(result); }
public void saveQuiz(quiz newQuiz) { try { using (studentlearnEntities1 db = new studentlearnEntities1()) { db.quizs.Add(newQuiz); db.SaveChanges(); } } catch (Exception e) { MessageBox.Show("İşlem sırasında bir hata meydana geldi." + e); } calcRate(); try { userrate newUserRate = new userrate(); newUserRate.userID = Convert.ToInt32(LoginUser.userID); newUserRate.paragraf = LoginUser.paragraf; newUserRate.dilbilgisi = LoginUser.dilbilgisi; newUserRate.anlatim = LoginUser.anlatim; newUserRate.siir = LoginUser.siir; newUserRate.divan = LoginUser.divan; newUserRate.date = DateTime.Now; using (studentlearnEntities1 db = new studentlearnEntities1()) { db.userrates.Add(newUserRate); db.SaveChanges(); } } catch (Exception e) { MessageBox.Show("İşlem sırasında bir hata meydana geldi." + e); } }