internal static Reponse Save(Reponse reponse) { string connStr = Utils.GetConn; using (MySqlConnection conn = new MySqlConnection(connStr)) { string sql = "INSERT INTO Reponse VALUES (@id, @texte, @niveau)"; if (reponse.Id != 0) { sql = "UPDATE Reponse SET r_texte = @texte, r_niveau = @niveau WHERE r_id = @id"; } conn.Open(); using (MySqlCommand cmd = new MySqlCommand(sql, conn)) { cmd.Parameters.Add(new MySqlParameter("@id", reponse.Id)); cmd.Parameters.Add(new MySqlParameter("@texte", reponse.Label)); cmd.Parameters.Add(new MySqlParameter("@niveau", reponse.NiveauId)); using (MySqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { fill(reponse, dr); } } } } return(reponse); }
private void BtnCommencer_Click(object sender, EventArgs e) { List <Quiz> quiz = QuizDAO.FindAll(); //Quiz quizz; Quiz quizz = comboBox1.SelectedItem as Quiz;//il faut caster selectedItem retourne un objet dc il faut que cet objet devin un quiz List <Question> questions = QuestionDAO.FindAll(quizz.QuizId); Question q = questions[0]; groupBox1.Text = q.Enonce; List <Reponse> Reponses = ReponseDAO.FindAll(quizz.QuizId); Reponse reponse = Reponses[0]; RadioButton nouveauBouton = new RadioButton { Name = "radioButton1", Location = new Point((MARGE + SIZE) * nbNouveauBouton + MARGE, 365), // Name = "RadioButtonNew" + ++nbNouveauBouton, Size = new Size(SIZE, 23), TabIndex = dernierTabIndex++, Text = reponse.Texte, // Location = new Point(409, 315); //TabStop = true; // UseVisualStyleBackColor = true; // CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); }; }
public void Load_Reponse() { idTest = 1; Reponse reponse = new Reponse(); using (MySqlConnection conn = new MySqlConnection(connStr)) { string sql = "SELECT * FROM Reponse WHERE r_id = @id"; conn.Open(); using (MySqlCommand cmd = new MySqlCommand(sql, conn)) { cmd.Parameters.Add(new MySqlParameter("@id", idTest)); using (MySqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { reponse.Id = (int)dr["r_id"]; reponse.Label = (string)dr["r_texte"]; } } } } Assert.AreEqual(reponse.Id, 1); Assert.AreEqual(reponse.Label, "300"); Trace.WriteLine("id: " + reponse.Id + " URL: " + reponse.Label); }
public async Task <ActionResult <Reponse> > PutReponse(int id, Reponse reponse) { if (id != reponse.id) { return(BadRequest()); } _context.Entry(reponse).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (await _context.Reponses.FindAsync(id) == null) { return(NotFound()); } else { throw; } } return(await _context.Reponses.FindAsync(id)); }
internal static List <Reponse> ListMauvaiseReponse(int id, NiveauIds niveau) { List <Reponse> listReponse = new List <Reponse>(); string connStr = Utils.GetConn; using (MySqlConnection conn = new MySqlConnection(connStr)) { string sql = "SELECT * FROM Reponse WHERE r_id != @id and r_niveau = @niveau"; conn.Open(); using (MySqlCommand cmd = new MySqlCommand(sql, conn)) { cmd.Parameters.Add(new MySqlParameter("@id", id)); cmd.Parameters.Add(new MySqlParameter("@niveau", niveau)); using (MySqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { Reponse reponse = new Reponse(); fill(reponse, dr); listReponse.Add(reponse); } } } } return(listReponse); }
/// <summary> /// Permet l'ajout d'une réponse dans la base de données. /// </summary> /// <param name="reponse">Réponse à ajouter.</param> /// <returns>L'identifiant de la réponse ajoutée.</returns> public async Task <int> AddAsync(Reponse reponse) { this.context.Reponses.Add(reponse); await this.context.SaveChangesAsync().ConfigureAwait(false); return(reponse.ReponseId); }
public void Initialise(int numeroDuParagraphe) { using (SqlConnection connection = new SqlConnection()) { connection.ConnectionString = Properties.Settings.Default.chaineConnexion; connection.Open(); using (SqlCommand commande = connection.CreateCommand()) { commande.CommandText = " SELECT Paragraphe.Contenu as contenuParagrahe, " + " Question.Texte as contenuQuestion, " + " Reponse.Texte as contenuReponse " + " FROM Paragraphe " + " JOIN Question on Paragraphe.Id = question.ParagrapheId " + " JOIN Reponse on Question.Id = Reponse.QuestionId " + " WHERE Paragraphe.Numero = " + numeroDuParagraphe + "; "; using (SqlDataReader reader = commande.ExecuteReader()) { this.MaQuestion = new Question(); this.MaQuestion.MesReponses = new List <Reponse>(); while (reader.Read()) { this.Contenu = reader["contenuParagrahe"].ToString(); this.MaQuestion.Contenu = reader["contenuQuestion"].ToString(); Reponse reponse = new Reponse(); reponse.Contenu = reader["contenuReponse"].ToString(); this.MaQuestion.MesReponses.Add(reponse); } } } } }
// GESTION POUR LE CHOIX UNIQUE public ActionResult VoteSimple(string onechoose, int idSondage) { ////////////////////////////////////////////////////////////////////////// if (TestSondagevote(Request.Cookies, idSondage)) { return(RedirectToAction("DejaVoter", new { idSondage = idSondage })); } //////////////////////////////////////////////////////////////////// Reponse model = new Reponse(idSondage); switch (onechoose) { case "Choix1": model.NombreVoteC1 = 1; break; case "Choix2": model.NombreVoteC2 = 1; break; case "Choix3": model.NombreVoteC3 = 1; break; case "Choix4": model.NombreVoteC4 = 1; break; } DataAccess.InsertionVoteBDD(idSondage, model.NombreVoteC1, model.NombreVoteC2, model.NombreVoteC3, model.NombreVoteC4); SaveCookie(idSondage); return(RedirectToAction("Resultat", new { IDSondage = idSondage })); }
public void MauvaisMessage() { const string p = "Snort"; byte[] hash; using (HMACSHA256 sha = new HMACSHA256(Key)) { hash = sha.ComputeHash(Encoding.UTF8.GetBytes(p)); } using (RdvController rc = new RdvController()) { rc.Request = new HttpRequestMessage(); rc.Configuration = new HttpConfiguration(); rc.Request.Headers.Add(LapinSignature, BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant()); rc.Request.Method = HttpMethod.Post; rc.Request.Content = new StringContent(p); HttpResponseMessage hrm = rc.NewCalendarEvent(); string s = hrm.Content.ReadAsStringAsync().Result; Reponse r = JsonConvert.DeserializeObject <Reponse>(s); Assert.IsTrue(r.Signature); Assert.IsTrue("Unexpected character encountered while parsing value: S. Path '', line 0, position 0.".Equals(r.Erreur, StringComparison.Ordinal)); } }
public HttpResponseMessage PostReponse(Reponse reponse) { if (userReponses.Add(reponse)) { return(new HttpResponseMessage(HttpStatusCode.Created)); } return(new HttpResponseMessage(HttpStatusCode.BadRequest)); }
public float RetournerValeurReponseCorrecte(string questionID, string optionID) { IEnumerable <Reponse> LstRep = GetAllResponseForQuestionID(int.Parse(questionID)); OptionReponse OpRep = _db.OptionReponses.FirstOrDefault(x => x.OptionReponseID.ToString() == optionID); Reponse rep = LstRep.First(x => x.Libelle == OpRep.Libelle); return(rep.NbrePoints); }
public ActionResult DeleteConfirmed(int id) { Reponse reponse = db.Reponses.Find(id); db.Reponses.Remove(reponse); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AddReponse(Reponse reponse) { if (ModelState.IsValid) { reponseService.ajouterReponse(reponse); } return(View()); }
public ActionResult Resultat(int idSondage) { Reponse sondage = DataAccess.AfficherQuestionReponse(idSondage); sondage.PourcentageDesVotes(); return(View(sondage)); }
public ActionResult CreateQuestion(QuestionViewModel model) { if (ModelState.IsValid) { CategorieQuest cat = categorieService.getCategorieById(model.CategorieID); Question q = new Question() { DescriptionQuest = model.DescriptionQuest, ReferenceQuest = model.ReferenceQuest, StatusQuest = model.StatusQuest, TypeQuest = model.TypeQuest, categorieId = model.CategorieID, categorieQuestion = cat }; switch (model.TypeQuest) { case TypeQuestion.DdlQuestion: List <string> listReponses = model.reponse.Split(',').ToList <string>(); for (int i = 0; i < listReponses.Count; i++) { List <string> reponseAnalyses = listReponses[i].Split(':').ToList <string>(); Reponse r = new Reponse { TextReponse = reponseAnalyses[0], AnalyseReponsePointsForts = reponseAnalyses[1], ValeurReponse = i }; q.Reponses.Add(r); } break; case TypeQuestion.NoteQuestion: break; case TypeQuestion.TextAreaQUestion: break; } //if(model.TypeQuest == TypeQuestion.QCM_Question) //{ // List<string> listReponses = model.reponse.Split(',').ToList<string>(); // for (int i = 0; i < listReponses.Count; i++) // { // List<string> reponseAnalyses = listReponses[i].Split(':').ToList<string>(); // Reponse r = new Reponse // { // TextReponse = reponseAnalyses[0], // AnalyseReponse = reponseAnalyses[1], // ValeurReponse = i // }; // q.Reponses.Add(r); // } //} questionService.ajouterQuestion(q); } return(View()); }
public IHttpActionResult Create([FromBody] Reponse reponse) { var reponseToAdd = new FR_DataAccessLayer.Models.Reponse { Libelle = reponse.Libelle }; reponseAccessLayer.Add(reponseToAdd); return(this.Ok("created")); }
public IActionResult Add(Reponse reponse) { if (this.ModelState.IsValid) { this._context.Reponses.Add(reponse); this._context.SaveChanges(); } this.ViewBag.QuestionList = this._context.Questions.ToList(); return(View(reponse)); }
public static IApplicationBuilder UseRabbitListener(this IApplicationBuilder app) { Listener = app.ApplicationServices.GetService <Reponse>(); var life = app.ApplicationServices.GetService <IApplicationLifetime>(); life.ApplicationStarted.Register(OnStarted); //press Ctrl+C to reproduce if your app runs in Kestrel as a console app life.ApplicationStopping.Register(OnStopping); return(app); }
public ActionResult Edit([Bind(Include = "IdReponse,LibelleReponse,IdQuestion")] Reponse reponse) { if (ModelState.IsValid) { db.Entry(reponse).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdQuestion = new SelectList(db.Questions, "IdQuestion", "LibelleQuestion", reponse.IdQuestion); return(View(reponse)); }
public Reponse GetReponse(string idReponse) { Reponse uneReponse = new Reponse(); if (_mesReponses.ContainsKey(idReponse)) { uneReponse = _mesReponses[idReponse]; } return(uneReponse); }
public bool ajouterReponse(Reponse reponse) { if (reponse != null) { repoRepository.Create(reponse); return(true); } else { return(false); } }
public IHttpActionResult Update(int id, [FromBody] Reponse reponse) { var reponseToUpdate = new FR_DataAccessLayer.Models.Reponse { Libelle = reponse.Libelle, ReponseId = reponse.ReponseId }; reponseAccessLayer.Update(reponseToUpdate); return(this.Ok("updated")); }
public async Task <IHttpActionResult> Create([FromBody] Reponse reponse) { var reponseToAdd = new AccessLayer.Models.Reponse { ReponseLib = reponse.ReponseLib, IsOk = reponse.IsOk }; await reponseAccessLayer.AddAsync(reponseToAdd); return(this.Ok("created")); }
public void TestAnswer2() { var array = new byte[] { 0x32, 0x45, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x04, 0xac, 0xd9, 0x14, 0x04 }; var a = new Reponse(array); //Assert.Equal(expected, actual); }
/// <summary> /// Ajouts the reponse sujet. /// </summary> /// <param name="reponse">The reponse.</param> /// <returns></returns> public Boolean ajoutReponseSujet(Reponse reponse) { Boolean fait = false; int longListReponse = listReponse.Count; listReponse.Add(reponse); if (longListReponse < listReponse.Count) { fait = true; } return(fait); }
public Boolean suppressionReponseSujet(Reponse reponse) { Boolean fait = false; int longListReponse = listReponse.Count; listReponse.Remove(reponse); if (longListReponse > listReponse.Count) { fait = true; } return(fait); }
public ActionResult Create([Bind(Include = "IdReponse,LibelleReponse,IdQuestion")] Reponse reponse) { if (ModelState.IsValid) { db.Reponses.Add(reponse); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdQuestion = new SelectList(db.Questions, "IdQuestion", "LibelleQuestion", reponse.IdQuestion); return(View(reponse)); }
public ActionResult PageVote(int idSondage) { Reponse model = DataAccess.AfficherQuestionReponse(idSondage); if (model.ModelSondage.IsDisabled == true) { return(RedirectToAction("ImpossibleDevoter", new { idSondage = idSondage })); } else { return(View(model)); } }
public async Task <IHttpActionResult> UpdateAsync([FromBody] Reponse reponse) { var reponseToUpdate = new AccessLayer.Models.Reponse { ReponseId = reponse.ReponseId, ReponseLib = reponse.ReponseLib, IsOk = reponse.IsOk }; await reponseAccessLayer.UpdateAsync(reponseToUpdate); return(this.Ok("updated")); }
public IActionResult Add(Reponse reponse) { if (ModelState.IsValid) { if (_daoReponse.AddReponse(reponse).IsCompleted) { return(RedirectToAction("Index")); } } ViewBag.MesQuestions = _questions; return(View(reponse)); }