private async void Start_Click(object sender, RoutedEventArgs e) { start.IsEnabled = false; output.Content += $"Je vais te préparer du pain 🍞 avec du beurre 🧀.{System.Environment.NewLine}"; var faireDuPainTache = FaireDuPainAsync(); var jeu = CasseTeteAsync(); //CasseTete(); Pain pain = await faireDuPainTache; output.Content += "Je tranche le pain\n"; etatPain.Content = "LE PAIN EST TRANCHÉ\n"; output.Content += "Je beurre le pain\n"; etatPain.Content = "LA TRANCHE EST BEURRÉE\n"; output.Content += $"Voila du pain 🍞 avec du beurre 🧀, mon lapin 🐰!{System.Environment.NewLine}"; await jeu; // Ranger le casse-tête start.IsEnabled = true; }
public void UpdatePain(Pain pPain) { //var _pain = (from p in context.Pain // where p.PainId == pPain.PainId // select p).FirstOrDefault(); //if (_pain != null) //{ context.Entry(pPain).State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); //} }
private async void OnSubmit() { Pain pain = new Pain(datePain, painValueSelected); int idUser = Convert.ToInt32(App.Current.Properties[PropertiesHelper.Id_User_Key]); User user = await App.Database.userRepo.GetWithChild(idUser); App.Database.painRepo.Insert(pain); user.painList.Add(pain); App.Database.userRepo.UpdateWithChild(user); await _navigationService.NavigateAsync("PainEvolution"); }
public IActionResult AddEdit(SessionPain pPain) { try { if (pPain != null) { Pain lPain = new Pain(); lPain.PatientId = pPain.PatientId; lPain.RxId = pPain.RxId; lPain.ProtocolId = pPain.ProtocolId; lPain.SessionId = pPain.SessionId; lPain.PainId = pPain.PainId; lPain.Angle = pPain.Angle; lPain.RepeatNumber = pPain.RepeatNumber; lPain.PainLevel = pPain.PainLevel; lPain.FlexionRepNumber = pPain.FlexionRepNumber; lPain.ExtensionRepNumber = pPain.ExtensionRepNumber; if (string.IsNullOrEmpty(lPain.PainId)) { lPain.PainId = Guid.NewGuid().ToString(); lIPainRepository.InsertPain(lPain); } else { lPain.PainId = pPain.PainId; //Pain editPain = lIPainRepository.getPain(pPain.PainId); //if (editPain != null) //{ lIPainRepository.UpdatePain(lPain); //} } } } catch (Exception ex) { logger.LogDebug("User Post Error: " + ex); } return(RedirectToAction("Index", "PainView", new { sessionId = pPain.SessionId, date = pPain.date, time = pPain.time, returnView = pPain.returnView })); }
/// <summary> /// This generates the conditions of the new cow /// </summary> private void GenerateConditions() { //:TODO: add individual variation into fuzzy distributions // Wellness - Physical conditions m_Pain = new Pain(this); m_Sick = new Sick(this); m_Wounded = new Wounded(this); m_Damage = new Damage(this); m_Tired = new Tired(this); m_Hungry = new Hungry(this); m_Thirsty = new Thirsty(this); m_Dead = new Dead(this); // Contentment - Mental conditions m_Anger = new Angry(this); m_Sleepy = new Sleepy(this); m_Scared = new Scared(this); m_Bored = new Bored(this); m_Lonely = new Lonely(this); m_Happy = new Happy(this); m_Eager = new Eager(this); }
public void InsertPain(Pain pPain) { context.Pain.Add(pPain); context.SaveChanges(); }
public IActionResult Post([FromBody] List <Pain> pPains, string sessionid) { ErrorResponse error = new ErrorResponse(); var response = new Dictionary <string, object>(); try { logger.LogDebug("Pain Post Start"); if (pPains != null && pPains.Count > 0 && !string.IsNullOrEmpty(sessionid)) { Patient lpatient = IPatient.GetPatientBySessionID(sessionid); if (lpatient != null) { foreach (Pain pPain in pPains) { if (!string.IsNullOrEmpty(pPain.PainId)) { if (pPain.PainLevel > 0) { Pain lPain = lIPainRepository.getPain(pPain.PainId); if (lPain == null) { pPain.PatientId = lpatient.PatientId; lIPainRepository.InsertPain(pPain); } else { lPain.PatientId = lpatient.PatientId; lPain.RxId = pPain.RxId; lPain.ProtocolId = pPain.ProtocolId; lPain.SessionId = pPain.SessionId; lPain.Angle = pPain.Angle; lPain.RepeatNumber = pPain.RepeatNumber; lPain.PainLevel = pPain.PainLevel > 0 ? pPain.PainLevel : 0; lPain.FlexionRepNumber = pPain.FlexionRepNumber; lPain.ExtensionRepNumber = pPain.ExtensionRepNumber; lIPainRepository.UpdatePain(pPain); } } else { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "Painlevel should not aceept negative values", TimeZone = DateTime.UtcNow.ToString("s") })); } } else { return(Json(new { Status = (int)HttpStatusCode.BadRequest, result = "Pain Request string is not in proper", TimeZone = DateTime.UtcNow.ToString("s") })); } } return(Json(new { Status = (int)HttpStatusCode.OK, result = "Pain inserted successfully", TimeZone = DateTime.UtcNow.ToString("s") })); } else { return(Json(new { Status = (int)HttpStatusCode.BadRequest, result = "patient session is not valid", TimeZone = DateTime.UtcNow.ToString("s") })); } } else { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "Pain insertion failed", TimeZone = DateTime.UtcNow.ToString("s") })); } } catch (Exception ex) { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "Pain insertion failed", TimeZone = DateTime.UtcNow.ToString("s") })); } }
public IActionResult ImportPains(IFormFile fileInput, string id, string date = "", string time = "", string returnView = "") { try { if (fileInput == null || fileInput.Length == 0) { TempData["msg"] = "<script>Helpers.ShowMessage('File is not selected', 1);</script>"; } else if (fileInput != null && !string.IsNullOrEmpty(fileInput.FileName.Trim())) { if (fileInput.FileName.Remove(0, fileInput.FileName.LastIndexOf(".") + 1) != "csv") { TempData["msg"] = "<script>Helpers.ShowMessage('Invalid csv file for Pain upload', 1);</script>"; } else { if (!string.IsNullOrEmpty(id)) { List <PainImport> lpains = new List <PainImport>(); using (var reader = new StreamReader(fileInput.OpenReadStream())) { using (var csv = new CsvReader(reader)) { csv.Configuration.IgnoreQuotes = true; csv.Configuration.IgnoreReferences = true; csv.Configuration.DetectColumnCountChanges = true; csv.Configuration.IgnoreBlankLines = true; lpains = csv.GetRecords <PainImport>().ToList(); } } if (lpains != null && lpains.Count > 0) { Session lsession = lISessionRepository.getSession(id); if (lsession != null) { for (int i = 0; i < lpains.Count; i++) { Pain pPain = new Pain(); pPain.PainId = Guid.NewGuid().ToString(); pPain.PatientId = lsession.PatientId; pPain.RxId = lsession.RxId; pPain.ProtocolId = lsession.ProtocolId; pPain.SessionId = lsession.SessionId; pPain.Angle = !string.IsNullOrEmpty(lpains[i].Angle) ? Convert.ToInt32(lpains[i].Angle) : (int?)null; pPain.RepeatNumber = !string.IsNullOrEmpty(lpains[i].RepeatNumber) ? Convert.ToInt32(lpains[i].RepeatNumber) : (int?)null; pPain.PainLevel = !string.IsNullOrEmpty(lpains[i].PainLevel) ? Convert.ToInt32(lpains[i].PainLevel) : (int?)null; pPain.FlexionRepNumber = !string.IsNullOrEmpty(lpains[i].FlexionRepNumber) ? Convert.ToInt32(lpains[i].FlexionRepNumber) : (int?)null; pPain.ExtensionRepNumber = !string.IsNullOrEmpty(lpains[i].ExtensionRepNumber) ? Convert.ToInt32(lpains[i].ExtensionRepNumber) : (int?)null; lIPainRepository.InsertPain(pPain); } } else { TempData["msg"] = "<script>Helpers.ShowMessage('Session details is not found', 1);</script>"; } } } } } else { TempData["msg"] = "<script>Helpers.ShowMessage('Please attach a file for Pain Upload', 1);</script>"; } } catch (Exception ex) { logger.LogDebug("User Post Error: " + ex); } return(RedirectToAction("Index", "PainView", new { sessionId = id, date = date, time = time, returnView = returnView })); }