public async Task <IActionResult> Edit(int id, [Bind("RegleID,description,commentaire")] Regle regle) { if (id != regle.RegleID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(regle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RegleExists(regle.RegleID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(regle)); }
public async Task <IActionResult> Create([Bind("RegleID,description,commentaire")] Regle regle) { if (ModelState.IsValid) { _context.Add(regle); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(regle)); }
public async Task <IActionResult> PutRegle([FromRoute] int id, [FromBody] Regle regle) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != regle.Id) { return(BadRequest()); } _context.Entry(regle).State = EntityState.Modified; if (regle.Image.Contains("Upload")) { System.Diagnostics.Debug.WriteLine(regle.Image); } else { System.Diagnostics.Debug.WriteLine("Base64"); var imagePath = ConvertImage(regle.Image); regle.Image = imagePath; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RegleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostRegle([FromBody] Regle regle) { /*if (!ModelState.IsValid) * { * return BadRequest(ModelState); * } * * _context.Regle.Add(regle); * await _context.SaveChangesAsync(); * * return CreatedAtAction("GetRegle", new { id = regle.Id }, regle);*/ var imagePath = ConvertImage(regle.Image); regle.Image = imagePath; _context.Regle.Add(regle); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRegle", new { id = regle.Id }, regle)); }
public OptionRule(Regle value) : base() { this.value = value; }
public new void Setup(Regle r, string num) { base.Setup(r, num); }
public void Setup(Regle r, string num) { this.regle = r; this.regleLabel.text = r.getDescription(); }
public bool respectRegles(string ordre, Regle regle) { bool ordreRespecteRegle = true; /*Coder vérification du respect des rêgles*/ StreamReader readerRegle = new StreamReader("regle.json"); StreamReader readerSituation = new StreamReader("voler.json"); string lectureRegle = readerRegle.ReadToEnd(); var resultRegle = JsonConvert.DeserializeObject <ApiAction>(lectureRegle); /* * * Dictionary<string, bool[]> respectList = new Dictionary<string, bool[]>(); * * foreach (ActionInstanciation a in result.actions) * { * bool[] respectRegle = new bool[rulesList.Count()]; * for (int i = 0; i < this.rulesList.Count(); i++) * { * if (a.getRegleList().Contains(this.rulesList[i].id)) * { * respectRegle[i] = true; * } * else * { * respectRegle[i] = false; * } * } * respectList.Add(a.getTag(), respectRegle); * * } * * int max = 0; * List<string> actionUtilisable = new List<string>(); * foreach (KeyValuePair<string, bool[]> couple in respectList) * { * int j = 0; * while (j < couple.Value.Length && couple.Value[j]) * { * j++; * } * if (j > max) * { * max = j; * actionUtilisable.Clear(); * actionUtilisable.Add(couple.Key); * } * else if (j == max) * { * actionUtilisable.Add(couple.Key); * } * } * int nbr = 0; * string actionUtilisé; * System.Random rand = new System.Random(); * nbr = rand.Next(actionUtilisable.Count()); * actionUtilisé = actionUtilisable[nbr]; * * this.setAction(actionUtilisé); * this.target = go;*/ return(ordreRespecteRegle); }