public JsonResult Put(Obituary ob) { string query = @" update dbo.Obituaries set Name = N'" + ob.Name + @"', DateOfDeath_Obituary = '" + ob.DateOfDeath_Obituary + @"', ObituaryContent = N'" + ob.ObituaryContent + @"' where Id = '" + ob.Id + @"'"; DataTable table = new DataTable(); string sqlDataSource = _configuration.GetConnectionString("CmentarzConnectionTEST"); SqlDataReader myReader; using (SqlConnection myCon = new SqlConnection(sqlDataSource)) { myCon.Open(); using (SqlCommand myCommand = new SqlCommand(query, myCon)) { myReader = myCommand.ExecuteReader(); table.Load(myReader);; myReader.Close(); myCon.Close(); } return(new JsonResult("Zaktualizowano nekrolog pomyślnie")); } }
public JsonResult Post(Obituary ob) { string query = @" insert into dbo.Obituaries values (N'" + ob.Name + @"', N'" + ob.DateOfDeath_Obituary + @"', N'" + ob.ObituaryContent + @"')"; DataTable table = new DataTable(); string sqlDataSource = _configuration.GetConnectionString("CmentarzConnectionTEST"); SqlDataReader myReader; using (SqlConnection myCon = new SqlConnection(sqlDataSource)) { myCon.Open(); using (SqlCommand myCommand = new SqlCommand(query, myCon)) { myReader = myCommand.ExecuteReader(); table.Load(myReader);; myReader.Close(); myCon.Close(); } return(new JsonResult("Dodano nekrolog pomyślnie")); } }
void Start() { display = canvas.GetComponent<Display>(); career = canvas.GetComponent<Career>(); relationship = canvas.GetComponent<Relationship>(); obituary = canvas.GetComponent<Obituary>(); panel.SetActive(false); }
public void DeleteObituary(Obituary obituary) { if (obituary == null) { throw new ArgumentException(nameof(obituary)); } _context.Obituaries.Remove(obituary); }
public void AddObituary(Obituary obituary) { if (obituary == null) { throw new ArgumentException(nameof(obituary)); } _context.Obituaries.Add(obituary); }
public ActionResult Endpoint() { Stream req = Request.InputStream; req.Seek(0, System.IO.SeekOrigin.Begin); string json = new StreamReader(req).ReadToEnd(); Obituary obituary = JsonConvert.DeserializeObject <Obituary>(json); // Vérifier si les secrets match if (obituary.Secret == Secret) { // Enregistre l'image if (!string.IsNullOrEmpty(obituary.Picture)) { // Retire le prefix string base64 = obituary.Picture.Split(',')[1]; // Convertir en array de bytes byte[] bytes = Convert.FromBase64String(base64); // Convertir les bytes en objet Image. using (MemoryStream ms = new MemoryStream(bytes)) { using (Image image = Image.FromStream(ms)) { // Sauvegarde de l'image string fileName = Guid.NewGuid().ToString().Replace("-", "") + ".jpg"; // Nom aléatoire. string path = Server.MapPath("~/Content/images/" + fileName); // Chemin de l'image image.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg); } } } // TODO : Enregistrer l'avis dans votre base de données. // Changer l'adresse de retour par une vraie adresse généré dans votre système. return(Content("https://www.example.com/obituary/john-doe")); } // Retourne rien si c'est pas valide. return(new EmptyResult()); }
public async Task TestRemovePictureIdFromUserObityarysAsyncMethod() { var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("testDb4"); var virtualDbContext = new ApplicationDbContext(optionsBuilder.Options); var obituaryRepository = new EFRepository <Obituary>(virtualDbContext); var pictureRepository = new EFRepository <Picture>(virtualDbContext); var userPictureService = new UserPictureService(pictureRepository, obituaryRepository); var obituary = new Obituary { Id = "ObituaryId1", UserId = "UserId1", FrameId = "frame1Id", TextTemplateId = "ttId1", CustomTextId = " CustomTextId1", CrossId = "1", PictureId = "PictureId1", AfterCrossTextId = "AfterCrossTextId1", CrossTextId = "CrossTextId1", FromId = "FromId1", FullNameId = "FullNameId1", PanahidaId = "PanahidaId1", YearId = "YearId1", }; await obituaryRepository.AddAsync(obituary); await obituaryRepository.SaveChangesAsync(); await userPictureService .RemovePictureIdFromUserObityarysAsync("PictureId1"); var dbObituary = obituaryRepository.All().FirstOrDefault(); Assert.Null(dbObituary.PictureId); }
public void UpdateObituary(Obituary obituary) { }
public void Start() { pausebutton.GetComponent<Button>().interactable = false; playbutton.GetComponent<Button>().interactable = true; fastbutton.GetComponent<Button>().interactable = true; infertileAge = Random.Range (37,45); glowing = true; glowUp = true; glowColor = Glowfade.color; glowColor.a = 0; FadeInCycle = 0; FadeIn = false; startTime = false; quickTime = false; startButton.interactable = false; maleToggle.isOn = true; playerIsMale = true; birthPanel.SetActive(true); deathfadeCount = 0; datingPanel.SetActive(false); deathPanel.SetActive(false); deathYear = 50 + Random.Range(0, 20) + Random.Range(0, 20) + Random.Range(0, 20); deathMonth = Random.Range(1, 12); startAge = 16; age = startAge; time = 0f; monthsSinceBirth = 0; alive = true; married = false; divorceCount = 0; monthCount = 2; status = "You are single"; fastforward = 0; partner = canvas.GetComponent<Partner>(); options = canvas.GetComponent<Options>(); relationship = canvas.GetComponent<Relationship>(); textupdate = canvas.GetComponent<TextUpdate>(); talk = canvas.GetComponent<Talk>(); obituary = canvas.GetComponent<Obituary>(); career = canvas.GetComponent<Career>(); colorName = partner.nameText.color; colorName.a = 0; relationshipCount = 0; marriageCount = 0; childrenCount = 0; pregnant = false; birthMonth = 0; birthYear = 0; durationMonths = 0; durationYears = 0; fastForwardCount = 0; fastTimeOn = false; partner.exName = ""; partner.exDuration = 0; maxHappiness = 50; jumpTime = 5; deathColor = Deathfade.color; birthColor = Birthfade.color; impendingDeath = false; relationship.playerpositiveemitter.GetComponent<ParticleSystem>().enableEmission = false; relationship.playernegativeemitter.GetComponent<ParticleSystem>().enableEmission = false; for ( int i = 0; i < 3; i++ ) { obituary.soNames[i] = ""; obituary.soLength[i] = 0; obituary.marriedSO[i] = false; obituary.soChildren[i] = 0; } if ( Random.Range (0,101) > 50) { nameCount = Random.Range(0,partner.maleNames.Length); playerName = partner.maleNames[nameCount]; } else { nameCount = Random.Range(0,partner.femaleNames.Length); playerName = partner.femaleNames[nameCount]; } inputNameText.text = playerName; monthInput.text = Random.Range (1,13).ToString(); yearInput.text = Random.Range (1950,1995).ToString(); impendingDeath = false; hotnessText.text = aspectText[0]; personalityText.text = aspectText[1]; wealthText.text = aspectText[2]; careerText.text = aspectText[3]; }
public async Task <string> SaveToDbAsync(SaveToDbInputModel input, string userId) { var frameId = framesRepository.All().Where(f => f.FilePath == input.Background) .Select(f => f.Id).FirstOrDefault(); var crossId = crossesRepository.All().Where(c => c.FilePath == input.Cross) .Select(c => c.Id).FirstOrDefault(); var pictureId = pictureRepository.All().Where(p => p.FilePath == input.Picture) .Select(p => p.Id).FirstOrDefault(); var crossText = crossTextsRepository.All() .Where(ct => ct.Text == input.CrossText) .FirstOrDefault(); var afterCrossText = afterCrossTextsRepository.All() .Where(act => act.Text == input.AfterCrossText) .FirstOrDefault(); var fullName = fullNamesRepository.All() .Where(fn => fn.Name == input.FullName) .FirstOrDefault(); var year = yearsRepository.All().Where(y => y.Text == input.Year).FirstOrDefault(); var textTemplate = textTemplatesRepository.All() .Where(t => t.Text == input.MainText).FirstOrDefault(); var panahida = panahidasRepository.All() .Where(p => p.Text == input.Panahida).FirstOrDefault(); var from = fromsRepository.All() .Where(f => f.Text == input.FromWhere).FirstOrDefault(); var obituary = new Obituary { UserId = userId, FrameId = frameId, CrossId = crossId, PictureId = pictureId, }; if (afterCrossText == null) { afterCrossText = new AfterCrossText { Text = input.AfterCrossText }; } obituary.AfterCrossTexts = afterCrossText; if (crossText == null) { crossText = new CrossText { Text = input.CrossText }; } obituary.CrossTexts = crossText; if (fullName == null) { fullName = new FullName { Name = input.FullName }; } obituary.FullNames = fullName; if (year == null) { year = new Year { Text = input.Year }; } obituary.Years = year; if (textTemplate == null) { var customText = new CustomText { Text = input.MainText }; obituary.CustomText = customText; } else { obituary.TextTemplate = textTemplate; } if (panahida == null) { panahida = new Panahida { Text = input.Panahida }; } obituary.Panahidas = panahida; if (from == null) { from = new From { Text = input.FromWhere }; } obituary.Froms = from; var userObituary = new UserObituary { Obituary = obituary, UserId = userId }; await obituaryRepository.AddAsync(obituary); await userObituaryRepository.AddAsync(userObituary); await obituaryRepository.SaveChangesAsync(); return(obituary.Id); }