public ActionResult AddChat(int id, Bericht bericht) { Account account = (Account)Session["loggedIn_Account"]; Contact contact = new Contact { ContactAccountID = id }; bericht = new Bericht { ChatBericht = bericht.ChatBericht, OntvangerID = contact.ContactAccountID, VerstuurderID = account.ID, DatumTijd = DateTime.Now }; if (ModelState.IsValid) { chatRepository.AddChat(bericht); return RedirectToAction("Index", "Contact"); }else{ ModelState.AddModelError("error", "Er is iets misgegaan.."); } return View(bericht); }
public async Task InitializeData() { _dbContext.Database.EnsureDeleted(); if (_dbContext.Database.EnsureCreated()) { //vul hier je eigen e-mailadres in Persoon superadmin = new Administrator("Moens", "Bart", "*****@*****.**", true); ((Administrator)superadmin).WachtwoordReset = true; _dbContext.Personen.Add(superadmin); Bericht welkom = new Bericht("Welkom", "Welkom bij Kairos!"); _dbContext.Berichten.Add(welkom); Doelgroep laaggeschoold = new Doelgroep("Jonger dan 25 en laaggeschoold", 2500M, 1550M); Doelgroep middengeschoold = new Doelgroep("Jonger dan 25 en middengeschoold", 2500M, 1000M); Doelgroep tussen55En60 = new Doelgroep("Tussen 55 en 60 jaar", 4466.66M, 1150M); Doelgroep boven60 = new Doelgroep("Boven 60 jaar", 4466.66M, 1500M); Doelgroep ander = new Doelgroep("Ander", 0M, 0M); _dbContext.Doelgroepen.Add(laaggeschoold); _dbContext.Doelgroepen.Add(middengeschoold); _dbContext.Doelgroepen.Add(tussen55En60); _dbContext.Doelgroepen.Add(boven60); _dbContext.Doelgroepen.Add(ander); _dbContext.SaveChanges(); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Titel,Inhoud,StartDate,AanvraagId,UserId")] Bericht bericht) { if (id != bericht.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bericht); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BerichtExists(bericht.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AanvraagId"] = new SelectList(_context.Aanvragen, "Id", "Omschrijving", bericht.AanvraagId); return(View(bericht)); }
public static void WijzigBericht(Bericht bericht) { Console.ForegroundColor = DarkMode ? ConsoleColor.White : ConsoleColor.Blue; using var context = new EFEindproefContext(); string nieuweTekst = ConsoleHelper.LeesString("Wijzig berichttekst", 250, OptionMode.Mandatory); bool? wijzigen = ConsoleHelper.LeesBool("Bericht Wijzigen", OptionMode.Mandatory); if (wijzigen == false) { Console.WriteLine(""); Console.WriteLine("Bericht niet gewijzigd."); Console.WriteLine(""); RaadplegenBerichten(Account); } else { bericht.BerichtTekst = nieuweTekst; bericht.BerichtTijdstip = DateTime.Now; context.Update(bericht); context.SaveChanges(); Console.WriteLine(""); Console.WriteLine($"Gemeente: {bericht.GemeenteId}"); Console.WriteLine($"BerichtType: {bericht.BerichtType}"); Console.WriteLine($"Titel: {bericht.BerichtTitel}"); Console.WriteLine($"Tekst: {bericht.BerichtTekst}"); Console.WriteLine($"Tijdstip: {bericht.BerichtTijdstip}"); Console.WriteLine($"Profiel {Account.LoginNaam}"); Console.WriteLine(""); Console.WriteLine("Bericht is gewijzigd."); Console.WriteLine(""); } }
public List <Bericht> GetAllBerichten() { List <Bericht> berichten = new List <Bericht>(); string query = "SELECT * FROM Bericht"; ConnectionString.Open(); using (var cmd = new SqlCommand(query, ConnectionString)) { using (var reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { var bericht = new Bericht() { BerichtId = (int)reader["BerichtId"], Gebruikersnaam = (string)reader["Gebruikersnaam"], GebruikerId = (int)reader["GebruikerId"], BerichtTitel = (string)reader["BerichtTitel"], Tekstbericht = (string)reader["Tekst"] }; berichten.Add(bericht); } } } } ConnectionString.Close(); return(berichten); }
public ActionResult AddChat(int id, Bericht bericht) { Account account = (Account)Session["loggedIn_Account"]; Contact contact = new Contact { ContactAccountID = id }; bericht = new Bericht { ChatBericht = bericht.ChatBericht, OntvangerID = contact.ContactAccountID, VerstuurderID = account.ID, DatumTijd = DateTime.Now }; if (ModelState.IsValid) { chatRepository.AddChat(bericht); return(RedirectToAction("Index", "Contact")); } else { ModelState.AddModelError("error", "Er is iets misgegaan.."); } return(View(bericht)); }
public int GetReportAmount(Bericht bericht) { int result = 0; using (SqlConnection connection = Database.Connection) { string query = "SELECT COUNT(*) FROM REPORT WHERE BERICHTID = @id"; using (SqlCommand command = new SqlCommand(query, connection)) { command.Parameters.AddWithValue("@id", bericht.ID); try { result = (int)command.ExecuteScalar(); } catch (SqlException) { // return 0; throw; } } } return(result); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Content,Datum")] Bericht bericht) { if (id != bericht.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bericht); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BerichtExists(bericht.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bericht)); }
public bool AddBericht(Bericht bericht) { string query = "INSERT INTO [dbo].[Bericht] ([GebruikerId],[Gebruikersnaam],[Tekst],[BerichtTitel])" + "VALUES (@GebruikerId, @Gebruikersnaam, @Tekst, @Titel)"; using (SqlCommand cmd = new SqlCommand(query, ConnectionString)) { cmd.Parameters.AddWithValue("@GebruikerId", bericht.GebruikerId); cmd.Parameters.AddWithValue("@Gebruikersnaam", bericht.Gebruikersnaam); cmd.Parameters.AddWithValue("@Tekst", bericht.Tekstbericht); cmd.Parameters.AddWithValue("@Titel", bericht.BerichtTitel); try { ConnectionString.Open(); int result = cmd.ExecuteNonQuery(); if (result == 0) { ConnectionString.Close(); return(false); } ConnectionString.Close(); return(true); } catch (Exception errorException) { throw errorException; } } }
public static void InvoerenNieuwBericht(Persoon persoon) { Console.ForegroundColor = DarkMode ? ConsoleColor.White : ConsoleColor.Blue; Console.WriteLine("Kies BerichtType*"); Console.WriteLine("-----------------"); using var context = new EFEindproefContext(); var berichttype = context.BerichtTypes.OrderBy(b => b.BerichtTypeId).ToList(); int berichtId; foreach (var item in berichttype) { Console.WriteLine($"{item.BerichtTypeId} {item.BerichtTypeNaam}"); } Console.WriteLine(""); Console.WriteLine("Geef het volgnummer uit de lijst: "); berichtId = Convert.ToInt32(Console.ReadLine()); var berichtgegevens = (from b in context.BerichtTypes where b.BerichtTypeId == berichtId select b).FirstOrDefault(); Console.WriteLine($"Gekozen BerichtType is {berichtgegevens.BerichtTypeCode} - {berichtgegevens.BerichtTypeNaam}"); Console.WriteLine(""); string titelBericht = ConsoleHelper.LeesString("Titel bericht", 50, OptionMode.Mandatory); string berichtTekst = ConsoleHelper.LeesString("Bericht", 250, OptionMode.Mandatory); bool? opslaan = ConsoleHelper.LeesBool("Nieuw bericht toevoegen ", OptionMode.Mandatory); DateTime tijdstip = DateTime.Now; Console.WriteLine(""); if (opslaan == false) { Console.ForegroundColor = DarkMode ? ConsoleColor.White : ConsoleColor.Red; Console.WriteLine("Bericht niet opgeslaan!"); KiesHoofdmenu(); } else { var bericht = new Bericht { GemeenteId = persoon.Adres.Straat.Gemeente.HoofdGemeente.GemeenteId, PersoonId = persoon.PersoonId, BerichtTypeId = berichtId, BerichtTijdstip = tijdstip, BerichtTitel = titelBericht, BerichtTekst = berichtTekst }; context.Berichten.Add(bericht); context.SaveChanges(); Console.WriteLine($"Gemeente : {persoon.Adres.Straat.Gemeente.HoofdGemeente.GemeenteNaam}"); Console.WriteLine($"BerichtType : {berichtgegevens.BerichtTypeNaam}"); Console.WriteLine($"Titel : {titelBericht}"); Console.WriteLine($"Tekst : {berichtTekst}"); Console.WriteLine($"Tijdstip : {tijdstip}"); Console.WriteLine($"Profiel : {persoon.LoginNaam}"); Console.WriteLine("Het bericht werd toegevoegd"); Console.WriteLine(""); KiesHoofdmenu(); } }
public async Task <Bericht> CreateBericht(Bericht newBericht) { await _berichtRepository.AddAsync(newBericht); await _berichtRepository.CommitAsync(); return(newBericht); }
public bool InsertBericht(Bericht bericht) { using (SqlConnection connection = Database.Connection) { int categorieid; string query; if (bericht.Bestand == null) { query = "INSERT INTO Bericht (ReplyTo, CategorieID, Tekst, AccountID) VALUES (@replyTo, @categorieid, @tekst, @accountid)"; } else { query = "INSERT INTO Bericht (ReplyTo, BestandID, CategorieID, Tekst, AccountID) VALUES (@replyTo, @bestandid, @categorieid, @tekst, @accountid)"; } using (SqlCommand command = new SqlCommand(query, connection)) { if (bericht.Bestand != null) { Bestand bestand = new Bestand { ID = GetMaxBerichtId() + 1, BestandArray = bericht.Bestand.BestandArray }; command.Parameters.AddWithValue("@bestandid", InsertBestand(bestand, connection)); } if (bericht.ReplyTo == null) { command.Parameters.AddWithValue("@replyto", 0); } else { command.Parameters.AddWithValue("@replyto", bericht.ReplyTo); } categorieid = InsertCategorie(bericht.Categorie, connection); command.Parameters.AddWithValue("@categorieid", categorieid); command.Parameters.AddWithValue("@tekst", bericht.Tekst); command.Parameters.AddWithValue("@accountid", bericht.AccountID); try { command.ExecuteNonQuery(); } catch (Exception) { throw; // return false; } } } return(true); }
public Woord CreateBerichtWoord(string berichtID, Woord woord) { Bericht bericht = ctx.Berichten.Find(berichtID); bericht.Woorden.Add(woord); UpdateBericht(bericht); return(woord); }
public Url CreateBerichtUrl(string berichtID, Url url) { Bericht bericht = ctx.Berichten.Find(berichtID); bericht.Urls.Add(url); UpdateBericht(bericht); return(url); }
public Hashtag CreateBerichtHashtag(string berichtID, Hashtag hashtag) { Bericht bericht = ctx.Berichten.Find(berichtID); bericht.Hashtags.Add(hashtag); UpdateBericht(bericht); return(hashtag); }
public Mention CreateBerichtMention(string berichtID, Mention mention) { Bericht bericht = ctx.Berichten.Find(berichtID); bericht.Mentions.Add(mention); UpdateBericht(bericht); return(mention); }
public MessageView(Bericht bericht) { BindingContext = this; InitializeComponent(); CurrentBericht = bericht; var a = (Gebruiker)Xamarin.Forms.Application.Current.Properties["loggedIn"]; Bericht[] berichten = new Bericht[] { CurrentBericht }; stackView.ItemsSource = berichten; }
public List <Bericht> LoadBerichtenByPostId(int id) { List <Bericht> berichtenList = new List <Bericht>(); using (SqlConnection connection = Connection.SQLconnection) { string query = "select * from BERICHT b " + "left join BIJDRAGE_BERICHT bb on bb.bericht_id = b.bijdrage_id left join BIJDRAGE bd on b.bijdrage_id = bd.ID where bb.bijdrage_id = @id"; using (SqlCommand command = new SqlCommand(query, connection)) { command.Parameters.AddWithValue("@id", id); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Bericht bericht = CreateBerichtFromReader(reader); berichtenList.Add(bericht); } } } foreach (Bericht bericht in berichtenList) { string query2 = "SELECT ab.* FROM ACCOUNT_BIJDRAGE ab LEFT JOIN bijdrage b ON ab.bijdrage_id = b.ID"; using (SqlCommand command = new SqlCommand(query2, connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { string ab = reader["id"].ToString(); string ab1 = reader["account_id"].ToString(); string ab2 = reader["bijdrage_id"].ToString(); string ab3 = reader["like"].ToString(); string ab4 = reader["ongewenst"].ToString(); if (bericht.Id == Convert.ToInt32(ab2)) { AccountBijdrage accountBijdrage1 = new AccountBijdrage(Convert.ToInt32(ab), Convert.ToInt32(ab1), Convert.ToInt32(ab2), Convert.ToInt32(ab3), Convert.ToInt32(ab4)); bericht.AccountBijdrage.Add(accountBijdrage1); } else { continue; } } } } } } return(berichtenList); }
public virtual ActionResult Details(string id) { Bericht bericht = mng.GetBericht(id); if (bericht == null) { return(Index()); } return(View(bericht)); }
//post public async Task <IActionResult> AddBericht(Bericht bericht) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var user = await _userManager.FindByIdAsync(userId); bericht.applicationuserId = userId; int aanvraagId = bericht.AanvraagId; var aanvraag = _context.Aanvragen.Where(x => x.Id == aanvraagId).Include(a => a.ApplicationUser).SingleOrDefault(); var status = await _context.Statussen.Where(s => s.Id.Equals(aanvraag.StatusId)).FirstOrDefaultAsync(); var behandelaar = _context.Users.Where(x => x.Id == bericht.applicationuserId).SingleOrDefault(); if (ModelState.IsValid) { var aanmaak = new AanvraagGeschiedenis { AanvraagId = aanvraag.Id, Aanvraag = aanvraag, Actie = "Bericht toegevoegd aan de aanvraag : " + bericht.Inhoud, time = DateTime.Now, Voornaam = user.Voornaam, Achternaam = user.Achternaam, Status = status.Naam }; _context.AanvraagGeschiedenis.Add(aanmaak); _context.Add(bericht); await _context.SaveChangesAsync(); // dat user van aanvraag zelf bericht plaatst if (bericht.applicationuser.Email == aanvraag.ApplicationUser.Email) { //mail naar user dat bericht geplaatst is await _emailSender.SendEmailAsync(user.Email, "Bericht voor aanvraag: " + aanvraag.Titel, $"Je bericht: " + bericht.Inhoud + " is succesvol geplaatst, de behandelaars zullen je zo spoedig mogelijk helpen."); //moet nog komen, mail naar behandelaar dat user bericht heeft geplaatst } //dat gebruiker bericht plaatst else if (bericht.applicationuser.Email != aanvraag.ApplicationUser.Email) { //mail naar user als behandelaar bericht plaatst await _emailSender.SendEmailAsync(aanvraag.ApplicationUser.Email, "Nieuw bericht voor aanvraag: " + aanvraag.Titel, $"De behandelaar: " + behandelaar.Voornaam + " " + behandelaar.Achternaam + " heeft het bericht met inhoud: " + bericht.Inhoud + " geplaatst, meer info vindt je terug in de details van je aanvraag."); //mail naar behandelaar dat bericht goed geplaatst is await _emailSender.SendEmailAsync(user.Email, "Bericht voor aanvraag: " + aanvraag.Titel, $"Je bericht: " + bericht.Inhoud + " is succesvol geplaatst."); } return(RedirectToAction("Details", "Aanvraags", new { id = aanvraagId })); } return(await AanvraagberichtenViewmodel(bericht.AanvraagId)); }
public async Task <IActionResult> Create([Bind("ID,Content,Datum")] Bericht bericht) { if (ModelState.IsValid) { _context.Add(bericht); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bericht)); }
public async Task <IActionResult> Create([Bind("Id,Titel,Inhoud,StartDate,AanvraagId,applicationuserId")] Bericht bericht) { if (ModelState.IsValid) { _context.Add(bericht); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AanvraagId"] = new SelectList(_context.Aanvragen, "Id", "Omschrijving", bericht.AanvraagId); return(View(bericht)); }
public ActionResult Create(Bericht bericht) { bericht.Datum = DateTime.Now; try { repository.Insert(new Bericht(bericht.Id, bericht.AccountId, bericht.Datum, bericht.Soort, bericht.Titel, bericht.Inhoud)); return(RedirectToAction("Index", "MediaSharing")); } catch { return(View()); } }
public IActionResult MaakBericht(BerichtViewModel model) { Bericht bericht = new Bericht(); bericht.Tekstbericht = model.Tekst; bericht.BerichtTitel = model.Titel; bericht.Gebruikersnaam = User.Identity.Name; bericht.GebruikerId = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value); ForumLogic logic = new ForumLogic(); logic.MaakBericht(bericht); return(RedirectToAction("Index")); }
// GET: Berichts/Create public IActionResult Create(int AanvraagId) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); Bericht bericht = new Bericht { AanvraagId = AanvraagId, applicationuserId = userId }; ViewData["AanvraagId"] = AanvraagId; return(View(bericht)); }
public bool Put(Bericht bericht) { var json = JsonConvert.SerializeObject(bericht); var response = Client.PutAsync(Url, new StringContent(json, Encoding.UTF8, "application/json")).Result; if (response.IsSuccessStatusCode) { return(true); } else { return(false); } }
public static List<Bericht> ImportBuchungen(string FilePath,Tuple<string,string>Verfasser,string unternehmen,string beruf,int berichtnr) { List<Bericht> Berichte = new List<Bericht>(); List<Tag> AlleTage = new List<Tag>(); StreamReader reader = new StreamReader(File.OpenRead(FilePath)); string headerLine = reader.ReadLine(); while (!reader.EndOfStream) { string line = reader.ReadLine(); if (!String.IsNullOrWhiteSpace(line)) { string[] values = line.Split(';'); Tag tag_ = new Tag(); for (int i = 0; i < values.Length; i++) { if(i == 0) { tag_ = new Tag(Convert.ToDateTime(values[i])); } else if(!string.IsNullOrEmpty(values[i])) { string buchungString = values[i]; Tuple<string, double> buchung = SplitBuchung(buchungString); Buchung buchung_ = new Buchung(buchung.Item1, buchung.Item2); tag_.Buchungen.Add(buchung_); } } AlleTage.Add(tag_); } } int count = berichtnr; for(int i = 0; i <= AlleTage.Count - 5; i = i + 5) { List<Tag> tageTemp = new List<Tag>(); tageTemp.Add(AlleTage[i]); tageTemp.Add(AlleTage[i + 1]); tageTemp.Add(AlleTage[i + 2]); tageTemp.Add(AlleTage[i + 3]); tageTemp.Add(AlleTage[i + 4]); Bericht berichtTemp = new Bericht(Verfasser, beruf, unternehmen, count, tageTemp); Berichte.Add(berichtTemp); count++; } return Berichte; }
private Bericht CreateBerichtFromReader(SqlDataReader reader) { Bericht bericht = new Bericht() { ID = Convert.ToInt32(reader["ID"]), ReplyTo = (reader["ReplyTo"] == DBNull.Value) ? null : (int?)(reader["ReplyTo"]), Tekst = Convert.ToString(reader["Tekst"]), AccountID = Convert.ToInt32(reader["AccountID"]), Categorie = GetCategorieById(Convert.ToInt32(reader["CategorieID"])), Bestand = GetBestandIdByBerichtId(Convert.ToInt32(reader["ID"])) }; bericht.AmountLikes = GetLikesAmount(bericht); return(bericht); }
public virtual ActionResult Search(string search) { if (search == null) { return(PartialView("_Resultaat")); } List <Persoon> personen = berichtMng.GetPersonen().Where(p => p.Naam.ToLower().Contains(search.ToLower())) .ToList(); string[] splitSearch = search.Split(' '); List <Woord> woorden = new List <Woord>(); List <Hashtag> hashtags = new List <Hashtag>(); List <Mention> mentions = new List <Mention>(); List <Url> urls = new List <Url>(); // List<Thema> themas = new List<Thema>(); List <Bericht> berichten = new List <Bericht>(); Bericht zoekresultaat = new Bericht(); foreach (string wrd in splitSearch) { woorden.AddRange(berichtMng.GetWoorden().Where(w => w.Tekst.ToLower().Contains(wrd.ToLower())) .ToList()); hashtags.AddRange(berichtMng.GetHashtags().Where(h => h.Tekst.ToLower().Contains(wrd.ToLower())) .ToList()); mentions.AddRange(berichtMng.GetMentions().Where(m => m.Tekst.ToLower().Contains(wrd.ToLower())) .ToList()); urls.AddRange(berichtMng.GetUrls().Where(u => u.Tekst.ToLower().Contains(wrd.ToLower())).ToList()); } //personen.Sort(); zoekresultaat.Woorden = woorden; zoekresultaat.Hashtags = hashtags; zoekresultaat.Mentions = mentions; zoekresultaat.Personen = personen; zoekresultaat.Urls = urls; //Sortering testSortering = new Sortering(); woorden.ToString(); return(View(zoekresultaat)); //return PartialView("_Resultaat",zoekresultaat); }
public bool Delete(Bericht bericht) { var json = JsonConvert.SerializeObject(bericht); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Delete, Url) { Content = new StringContent(json, Encoding.UTF8, "application/json") }; var response = Client.SendAsync(request).Result; if (response.IsSuccessStatusCode) { return(true); } else { return(false); } }
//post public async Task <IActionResult> AddBericht(Bericht bericht) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); bericht.applicationuserId = userId; int aanvraagId = bericht.AanvraagId; if (ModelState.IsValid) { _context.Add(bericht); await _context.SaveChangesAsync(); return(RedirectToAction("Details", "Aanvraags", new { id = aanvraagId })); } return(await AanvraagberichtenViewmodel(bericht.AanvraagId)); }
public void AddChat(Bericht chat) { ctx.Chats.Add(chat); ctx.SaveChanges(); }