public ActionResult Gegevens(int id) { if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"])) { return(View("~/Views/Error/AuthError.cshtml")); } try { GebruikerSqlContext sql = new GebruikerSqlContext(); GebruikerRepository repo = new GebruikerRepository(sql); VaardigheidSqlContext vsql = new VaardigheidSqlContext(); VaardigheidRepository vrepo = new VaardigheidRepository(vsql); ViewData["vaardigheden"] = vrepo.GetAll(); Gebruiker gebruiker = (from gebruikers in repo.GetUserWithType() where gebruikers.Id == id select gebruikers).First(); ViewData["gebruiker"] = gebruiker; return(View("GegevensWijzigen")); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }
//GET : Chat/{AnderegebruikerId} public ActionResult ChatScherm(string id) { if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"])) { return(View("~/Views/Error/AuthError.cshtml")); } try { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); var sql = new ChatSqlContext(); var chatRepo = new ChatRepository(sql); Gebruiker loggedInUser = (Gebruiker)Session["LoggedInUser"]; // Gebruiker loggedInUser = gr.GetById(1); ViewBag.LoggedInUser = loggedInUser; ViewBag.Gebruikers = gr.GetAll(); ViewBag.EnableChat = "true"; return(View("~/Views/Chat/Index.cshtml")); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }
// GET: Beheerder public ActionResult Index() { if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.Beheerder, (Gebruiker)Session["LoggedInUser"])) { return(View("~/Views/Error/AuthError.cshtml")); } try { BeheerderViewModel model = new BeheerderViewModel(); HulpvraagSqlContext hsc = new HulpvraagSqlContext(); HulpvraagRepository hr = new HulpvraagRepository(hsc); GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); model.LstGebruiker = gr.GetUserWithType(); model.LstHulpvraag = hr.GetAll(); return(View(model)); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }
public Gebruiker ReturnAutheurObj() { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); return(gr.GetById(this.AuteurId)); }
//Get /Details/{id} public ActionResult Details(int id) { if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"])) { return(View("~/Views/Error/AuthError.cshtml")); } // try { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); ReviewSqlContext rsc = new ReviewSqlContext(); ReviewRepository rr = new ReviewRepository(rsc); Gebruiker loggedUser = (Gebruiker)Session["LoggedInUser"]; ViewBag.SelectedUser = gr.GetById(id); if (loggedUser != null) { ViewBag.CanReview = rr.CanReview(loggedUser.Id, id); } ViewBag.SelectedUser = gr.GetById(id); ViewBag.Reviews = rr.GetReviewByVrijwilligerId(id); return(View("~/Views/Gebruiker/Details.cshtml")); // } /* * catch (Exception e) * { * return RedirectToAction("Index", "Error"); * } */ }
public void GetById() { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); int id = 1; var User = gr.GetById(id); Assert.AreEqual(id, User.Id); }
public void GetAll() { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); var Lijst = gr.GetAll(); Assert.IsTrue(Lijst.Count > 0); }
public void GetUserTypesByUserIdtest() { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); List <Gebruiker> glijst = gr.GetUserTypesByUserId(4); Assert.IsTrue(glijst.Count > 0); }
public void RetrieveWithType() { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); List <Gebruiker> list = gr.GetUserWithType(); Assert.IsTrue(list.Count > 5); }
public void Barcodetest() { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); var Lijst = gr.GetAll(); Assert.IsTrue(Lijst[0].Barcode == null); Assert.IsTrue(Lijst[1].Barcode == "12345"); }
public void Update() { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); Gebruiker g = gr.GetById(1); g.Uitschrijfdatum = DateTime.Now; g.Naam = g.Naam + "aangepast"; gr.Update(g); }
public void Create() { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); var User = gr.GetById(1); int id = gr.Create(User); var nieuweUser = gr.GetById(id); Assert.AreEqual(id, nieuweUser.Id); }
public ActionResult RegistreerHulpverlener(FormCollection form, HttpPostedFileBase foto) { try { string path = ""; string fotoPath = ""; if (foto != null) { if (foto.ContentLength > 0) { if (Path.GetExtension(foto.FileName).ToLower() == ".png" || Path.GetExtension(foto.FileName).ToLower() == ".jpg" || Path.GetExtension(foto.FileName).ToLower() == ".jpeg") { path = Path.Combine(Server.MapPath("~/Content/Foto"), foto.FileName); foto.SaveAs(path); fotoPath = "/Content/Foto/" + foto.FileName; } } } if (form["wachtwoord"] == form["wachtwoordherhalen"]) { Gebruiker gebruiker1 = new Gebruiker(); gebruiker1.Image = fotoPath; gebruiker1.Geslacht = (Geslacht)Enum.Parse(typeof(Geslacht), form["geslacht"]); gebruiker1.Adres = form["adres"]; gebruiker1.Email = form["email"]; gebruiker1.Geboortedatum = Convert.ToDateTime(form["geboortedatum"]); gebruiker1.Woonplaats = form["plaats"]; gebruiker1.Land = form["land"]; gebruiker1.Postcode = form["postcode"]; gebruiker1.Telefoonnummer = form["telnr"]; gebruiker1.Wachtwoord = form["wachtwoord"]; gebruiker1.Gebruikersnaam = form["gebruikersnaam"]; gebruiker1.Naam = form["naam"]; gebruiker1.Barcode = form["barcode"]; GebruikerSqlContext sql = new GebruikerSqlContext(); GebruikerRepository repo = new GebruikerRepository(sql); int id = repo.Create(gebruiker1); Hulpverlener hulpverlener = new Hulpverlener(id); HulpverlenerSqlContext hsql = new HulpverlenerSqlContext(); HulpverlenerRepository hrepo = new HulpverlenerRepository(hsql); hrepo.Create(id); return(RedirectToAction("Index", "Login")); } return(RedirectToAction("RegistreerHulpverlener", "Registreer")); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }
public void Delete() { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); int oudeCount = gr.GetAll().Count; // gr.Delete(3); int nieuweCount = gr.GetAll().Count; Assert.AreEqual(oudeCount, (nieuweCount - 1)); }
public void TestCreateChat() { var sql = new ChatSqlContext(); var repo = new ChatRepository(sql); var gsql = new GebruikerSqlContext(); var grepo = new GebruikerRepository(gsql); var g1 = grepo.GetById(1); var g2 = grepo.GetById(4); var chat = new Chat(g1, g2, DateTime.Now, "Hallo jongens"); repo.Create(chat); }
public JsonResult SendChatMessage(int autheurId, int ontvangerId, string bericht) { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); var sql = new ChatSqlContext(); var chatRepo = new ChatRepository(sql); Gebruiker auteur = gr.GetById(autheurId); Gebruiker ontvanger = gr.GetById(ontvangerId); Chat nieuwBericht = new Chat(auteur, ontvanger, DateTime.Now, bericht); chatRepo.Create(nieuwBericht); return(null); }
public static Gebruiker CheckAuthBarcode(string barCode) { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); List <Gebruiker> gebruikers = gr.GetAll(); foreach (Gebruiker g in gebruikers) { if (g.Barcode == barCode) { return(g); } } return(null); }
public static Gebruiker CheckAuth(string email, string password) { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); List <Gebruiker> gebruikers = gr.GetAll(); foreach (Gebruiker g in gebruikers) { if (g.Email == email && g.Wachtwoord == password) { return(g); } } return(null); }
//Get: Beheerder/Chat public ActionResult Chat(FormCollection f) { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); ChatSqlContext csc = new ChatSqlContext(); ChatRepository cr = new ChatRepository(csc); List <Gebruiker> users = gr.GetAll(); int id1 = Convert.ToInt32(f["user1"]); int id2 = Convert.ToInt32(f["user2"]); if (id1 != 0 && id2 != 0 && (id1 != id2)) { List <Chat> chat = cr.GetChatByUsers(id1, id2); string chatString = ""; if (chat.Count > 0) { for (int i = 0; i < chat.Count; i++) { chatString = chatString + chat[i].Auteur.Naam + " | " + chat[i].Bericht + "\r"; } ViewBag.Chatstring = chatString; } else { ViewBag.Chatstring = "Geen chat gevonden"; } } else { ViewBag.Chatstring = ""; } ViewBag.Users = users; return(View("~/Views/Chat/Beheer.cshtml")); }
// GET: Chat public ActionResult Index() { if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"])) { return(View("~/Views/Error/AuthError.cshtml")); } try { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); Gebruiker g = (Gebruiker)Session["LoggedInUser"]; ViewBag.Gebruikers = gr.GetAll().Where(x => x.Id != g.Id).ToList(); return(View("~/Views/Chat/Index.cshtml")); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }
public ActionResult KeuzeRedirect(string id) { GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); GebruikerType gt = (GebruikerType)Enum.Parse(typeof(GebruikerType), id); List <Gebruiker> users = gr.GetUserTypesByUserId((int)Session["UserId"]); List <GebruikerType> types = new List <GebruikerType>(); foreach (Gebruiker gebr in users) { types.Add((GebruikerType)Enum.Parse(typeof(GebruikerType), gebr.GetType().Name)); } foreach (GebruikerType type in types) { if (type == gt) { if (type == GebruikerType.Vrijwilliger) { VrijwilligerSqlContext vsc = new VrijwilligerSqlContext(); VrijwilligerRepository vr = new VrijwilligerRepository(vsc); Session["LoggedInUser"] = vr.GetVrijwilligerById((int)Session["UserId"]); return(RedirectToAction("Index", "Vrijwilliger")); } if (type == GebruikerType.Hulpbehoevende) { HulpbehoevendeSqlContext hsc = new HulpbehoevendeSqlContext(); HulpbehoevendeRepository hr = new HulpbehoevendeRepository(hsc); Session["LoggedInUser"] = hr.GetHulpbehoevendeById((int)Session["UserId"]); return(RedirectToAction("Index", "Hulpbehoevende")); } } } return(null); }
public ActionResult Delete(int id) { if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"])) { return(View("~/Views/Error/AuthError.cshtml")); } try { GebruikerSqlContext gsql = new GebruikerSqlContext(); GebruikerRepository grepo = new GebruikerRepository(gsql); grepo.Delete(id); Gebruiker gebruiker = (Gebruiker)Session["LoggedInUser"]; if (gebruiker.GetType() == typeof(Beheerder)) { return(RedirectToAction("Index", "Beheerder")); } return(RedirectToAction("Index", "Login")); } catch (Exception) { return(RedirectToAction("Index", "Error")); } }
public ActionResult Update(FormCollection form, int id, HttpPostedFileBase foto) { if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"])) { return(View("~/Views/Error/AuthError.cshtml")); } try { if (Session["LoggedInUser"] != null) { Gebruiker loggedinGebruiker = Session["LoggedInUser"] as Gebruiker; GebruikerSqlContext sql = new GebruikerSqlContext(); GebruikerRepository repo = new GebruikerRepository(sql); VrijwilligerSqlContext vsql = new VrijwilligerSqlContext(); VrijwilligerRepository vrepo = new VrijwilligerRepository(vsql); Gebruiker gebruiker = new Gebruiker(); gebruiker.Id = id; string path = ""; string fotoPath = ""; if (foto != null) { if (foto.ContentLength > 0) { if (Path.GetExtension(foto.FileName).ToLower() == ".png" || Path.GetExtension(foto.FileName).ToLower() == ".jpg" || Path.GetExtension(foto.FileName).ToLower() == ".jpeg") { path = Path.Combine(Server.MapPath("~/Content/Foto"), foto.FileName); foto.SaveAs(path); fotoPath = "/Content/Foto/" + foto.FileName; gebruiker.Image = fotoPath; } } } else { gebruiker.Image = loggedinGebruiker.Image; } if (form["wachtwoord"] != "" && form["wachtwoordnieuw"] != "") { if (form["wachtwoord"] == form["wachtwoordnieuw"]) { gebruiker.Wachtwoord = form["wachtwoord"]; } } else { gebruiker.Wachtwoord = loggedinGebruiker.Wachtwoord; } gebruiker.Geslacht = (Geslacht)Enum.Parse(typeof(Geslacht), form["geslacht"]); gebruiker.Adres = form["adres"]; gebruiker.Email = form["email"]; gebruiker.Woonplaats = form["plaats"]; gebruiker.Land = form["land"]; gebruiker.Postcode = form["postcode"]; gebruiker.Telefoonnummer = form["telnr"]; gebruiker.Gebruikersnaam = form["gebruikersnaam"]; gebruiker.Naam = form["naam"]; gebruiker.HeeftAuto = Convert.ToBoolean(form["auto"]); gebruiker.HeeftRijbewijs = Convert.ToBoolean(form["rijbewijs"]); gebruiker.HeeftOv = Convert.ToBoolean(form["ov"]); gebruiker.Barcode = form["barcode"]; string[] vaardigheidIds = form.GetValues("vaardigheden"); List <int> vaardigheidIdList = new List <int>(); if (vaardigheidIds != null) { foreach (string vaardigheidId in vaardigheidIds) { vaardigheidIdList.Add(Convert.ToInt32(vaardigheidId)); } } if (vaardigheidIdList.Count != 0) { vrepo.CreateVrijwilligerWithVaardigheid(gebruiker.Id, vaardigheidIdList); } repo.Update(gebruiker); return(RedirectToAction("Gegevens", "Gebruiker", new { id = gebruiker.Id })); } return(RedirectToAction("Index", "Login")); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }
public ActionResult Save(FormCollection form, HttpPostedFileBase foto, HttpPostedFileBase vog) { try { string vogPath = ""; string path = ""; if (vog != null) { if (vog.ContentLength > 0) { if (Path.GetExtension(vog.FileName).ToLower() == ".pdf") { path = Path.Combine(Server.MapPath("~/Content/VOG"), vog.FileName); vog.SaveAs(path); vogPath = "/Content/VOG/" + vog.FileName; } } } string fotoPath = ""; if (foto != null) { if (foto.ContentLength > 0) { if (Path.GetExtension(foto.FileName).ToLower() == ".png" || Path.GetExtension(foto.FileName).ToLower() == ".jpg" || Path.GetExtension(foto.FileName).ToLower() == ".jpeg") { path = Path.Combine(Server.MapPath("~/Content/Foto"), foto.FileName); foto.SaveAs(path); fotoPath = "/Content/Foto/" + foto.FileName; } } } if (form["vrij"] == null && form["hulp"] == null) { return(RedirectToAction("Index", "Registreer")); } if (form["wachtwoord"] == form["wachtwoordherhalen"]) { Gebruiker gebruiker1 = new Gebruiker(); gebruiker1.Image = fotoPath; gebruiker1.Geslacht = (Geslacht)Enum.Parse(typeof(Geslacht), form["geslacht"]); gebruiker1.Adres = form["adres"]; gebruiker1.Email = form["email"]; gebruiker1.Geboortedatum = Convert.ToDateTime(form["geboortedatum"]); gebruiker1.Woonplaats = form["plaats"]; gebruiker1.Land = form["land"]; gebruiker1.Postcode = form["postcode"]; gebruiker1.Telefoonnummer = form["telnr"]; // gebruiker1.Huisnummer = form["huisnr"]; gebruiker1.Wachtwoord = form["wachtwoord"]; gebruiker1.Gebruikersnaam = form["gebruikersnaam"]; gebruiker1.Naam = form["naam"]; gebruiker1.HeeftAuto = bool.Parse(form["auto"]); gebruiker1.HeeftRijbewijs = bool.Parse(form["rijbewijs"]); gebruiker1.HeeftOv = bool.Parse(form["ov"]); gebruiker1.Barcode = form["barcode"]; string[] vaardigheidIds = form.GetValues("vaardigheden"); List <int> vaardigheidIdList = new List <int>(); if (vaardigheidIds != null) { foreach (string vaardigheidId in vaardigheidIds) { vaardigheidIdList.Add(Convert.ToInt32(vaardigheidId)); } } GebruikerSqlContext sql = new GebruikerSqlContext(); GebruikerRepository repo = new GebruikerRepository(sql); int id = repo.Create(gebruiker1); if (form["hulp"] != null && form["hulp"] == "hulpbehoevende") { Hulpbehoevende hulpbehoevende = new Hulpbehoevende(id); hulpbehoevende.Id = id; HulpbehoevendeSqlContext hsql = new HulpbehoevendeSqlContext(); HulpbehoevendeRepository hrepo = new HulpbehoevendeRepository(hsql); hrepo.CreateHulpbehoevende(hulpbehoevende.Id, hrepo.BepaalHulpverlener()); } if (form["vrij"] != null && form["vrij"] == "vrijwilliger") { Vrijwilliger vrijwilliger = new Vrijwilliger(id, vogPath, false); VrijwilligerSqlContext vsql = new VrijwilligerSqlContext(); VrijwilligerRepository vrepo = new VrijwilligerRepository(vsql); vrepo.Create(vrijwilliger.Id, vrijwilliger.VOG); if (vaardigheidIdList.Count != 0) { vrepo.CreateVrijwilligerWithVaardigheid(vrijwilliger.Id, vaardigheidIdList); } } return(RedirectToAction("Index", "Login")); } return(RedirectToAction("Index", "Registreer")); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }
public ActionResult Barcode(FormCollection form) { try { Gebruiker g = AuthRepository.CheckAuthBarcode(form["barcode"]); GebruikerSqlContext gsc = new GebruikerSqlContext(); GebruikerRepository gr = new GebruikerRepository(gsc); if (g == null) { ViewBag.LoginResult = false; return(View("~/Views/Login/Login.cshtml")); } List <Gebruiker> users = gr.GetUserTypesByUserId(g.Id); List <GebruikerType> types = new List <GebruikerType>(); foreach (Gebruiker gebr in users) { types.Add((GebruikerType)Enum.Parse(typeof(GebruikerType), gebr.GetType().Name)); } if (types.Contains(GebruikerType.Hulpbehoevende) && types.Contains(GebruikerType.Vrijwilliger)) { ViewBag.Accounts = users; ViewBag.Types = types; Session["UserId"] = g.Id; return(Keuze()); } if (types.Contains(GebruikerType.Hulpbehoevende)) { HulpbehoevendeSqlContext hsc = new HulpbehoevendeSqlContext(); HulpbehoevendeRepository hr = new HulpbehoevendeRepository(hsc); Session["LoggedInUser"] = hr.GetHulpbehoevendeById(g.Id); return(RedirectToAction("Index", "Hulpbehoevende")); } if (types.Contains(GebruikerType.Vrijwilliger)) { VrijwilligerSqlContext vsc = new VrijwilligerSqlContext(); VrijwilligerRepository vr = new VrijwilligerRepository(vsc); Session["LoggedInUser"] = vr.GetVrijwilligerById(g.Id); return(RedirectToAction("Index", "Vrijwilliger")); } if (types.Contains(GebruikerType.Beheerder)) { BeheerderSqlContext bsc = new BeheerderSqlContext(); BeheerderRepository br = new BeheerderRepository(bsc); Session["LoggedInUser"] = br.GetById(g.Id); return(RedirectToAction("Index", "Beheerder")); } if (types.Contains(GebruikerType.Hulpverlener)) { HulpverlenerSqlContext hsc = new HulpverlenerSqlContext(); HulpverlenerRepository hr = new HulpverlenerRepository(hsc); Session["LoggedInUser"] = hr.GetById(g.Id); return(RedirectToAction("Index", "Hulpverlener")); } return(RedirectToAction("Index", "Login")); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }