public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Activiteit activiteit = db.Activiteits.Find(id); if (activiteit == null) { return(HttpNotFound()); } if (!User.Identity.IsAuthenticated) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } int userId = Convert.ToInt32(User.Identity.GetUserId()); EvenementBeheerder evenementBeheerder = db.Evenements.Find(activiteit.evenement).EvenementBeheerders.FirstOrDefault(b => b.beheerder == userId); if (evenementBeheerder == null) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } return(View(activiteit)); }
// GET: Activiteiten/Create public ActionResult Create(int?evenement_id) { if (evenement_id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (!User.Identity.IsAuthenticated) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } int userId = Convert.ToInt32(User.Identity.GetUserId()); EvenementBeheerder evenementBeheerder = db.Evenements.Find(evenement_id).EvenementBeheerders.FirstOrDefault(b => b.beheerder == userId); if (evenementBeheerder == null) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } Activiteit activiteit = new Activiteit { evenement = (int)evenement_id, evenement_beheerder = evenementBeheerder.evenement_beheerder_id }; return(View(activiteit)); }
public void Update(Activiteit activiteit) { //alle activiteitleden van deze activiteit verwijderen List <GebruikerActiviteit> alleActiviteitLeden = _gebruikerActiviteit.ToList(); alleActiviteitLeden.ForEach(gebruikerActiviteit => { if (gebruikerActiviteit.Activiteit == activiteit) { _gebruikerActiviteit.Remove(gebruikerActiviteit); } }); //alle activiteitleden van deze activiteit opnieuw toevoegen if (activiteit.GebruikersApi != null) { activiteit.GebruikersApi.ForEach(a => { _gebruikerActiviteit.Add(new GebruikerActiviteit(activiteit, a)); }); } _activiteiten.Update(activiteit); SaveChanges(); }
public IActionResult KokenStudentenhuis(int[] VoorGebr, DateTime DatumVanActiviteit, int VanGebruiker, string Beschrijving, string bedrag, int studentenhuisid, string KokenOfVoorschieten) { Activiteit activi = new Activiteit { Datum = DatumVanActiviteit, Beschrijving = Beschrijving, Bedrag = Convert.ToInt32(bedrag), StudentenhuisID = studentenhuisid, IngelogdeGebruiker = VanGebruiker }; if (KokenOfVoorschieten == "koken") { QueryFeedback feedback = gebruikLogic.KokenVoorHuisgenoten(VoorGebr, activi); if (!feedback.Gelukt) { RedirectToAction("Error", "Home"); } return(RedirectToAction("Dashboard", "Home")); } else if (KokenOfVoorschieten == "voorgeschoten") { QueryFeedback VoegActiviteitToe = gebruikLogic.VoorschitenVoorHuisgenoten(VoorGebr, activi); if (VoegActiviteitToe.Gelukt) { return(RedirectToAction("Dashboard", "Home")); } return(Content($"hetis niet gelukt omdat {VoegActiviteitToe.Message}")); } else { return(Content("Selecteet of je kookt of iets voorschiet")); } }
public async Task <IActionResult> Create([Bind("Id,Naam,Omschrijving,Publicatiedatum,Uiterste_inschrijfdatum,Prijs,Max_inschrijvingen,Id_ontmoetingsplaats,Activiteitendatum,Beginuur,Einduur")] Activiteit activiteit) { // mag de huidige gebruiker (indien gekend) deze gegevens opslaan // als het resultaat null is, mag hij de gegevens opslaan // als het resultaat niet null is, toon dan de gepaste pagina (login of unauthorized) IActionResult actionResult = CredentialBeheerder.CheckIfAllowed(_role, TempData, _context);; if (actionResult != null) { return(actionResult); } // zijn er geen validatie fouten // voeg dan de nieuwe activiteit toe aan de db if (ModelState.IsValid) { activiteit.Id = Guid.NewGuid(); //verander de punt (Engelse getalnotatie) naar een komma (onze getalnotatie) NormalizePrijs(activiteit); _context.Add(activiteit); await _context.SaveChangesAsync(); // keer terug naar de lijst met activiteiten return(RedirectToAction(nameof(Index))); } //indien hier was er een fout met de validatie //vul de select lijst op met de naam van de ontmoetingsplaatsen ViewData["Id_ontmoetingsplaats"] = new SelectList(_context.Ontmoetingsplaatsen, "Id", "Plaatsnaam", activiteit.Id_ontmoetingsplaats); //blijf op de huidige pagina return(View(activiteit)); }
public ActionResult DeleteConfirmed(int id) { Activiteit activiteitProxy = db.Activiteits.Find(id); //Create non proxy copy Activiteit activiteit = new Activiteit { activiteit_id = id, naam = activiteitProxy.naam, beschrijving = activiteitProxy.beschrijving, evenement = activiteitProxy.evenement, evenement_beheerder = activiteitProxy.evenement_beheerder, begintijd = activiteitProxy.begintijd, eindtijd = activiteitProxy.eindtijd }; if (db.Evenements.Find(activiteit.evenement).EvenementBeheerders.Count() > 1) { TempData["wijziging"] = GenerateWijziging(activiteit, 2); return(RedirectToAction("Create", "Wijzigingen", null)); } else { db.Activiteits.Remove(activiteitProxy); db.SaveChanges(); return(RedirectToAction("Dashboard", "Evenementen", new { id = activiteit.evenement })); } }
public IEnumerable <Activiteit> GetAll() { List <Activiteit> alleActiviteitsen = _activiteiten.ToList(); List <int> gebruikersAct = new List <int>(); List <Activiteit> hulpList = new List <Activiteit>(); alleActiviteitsen.ForEach(act => { gebruikersAct.Clear(); if (act.GebruikersApi == null) { act.GebruikersApi = new List <Gebruiker>(); } List <GebruikerActiviteit> gebruikerActiviteits = _gebruikerActiviteit.Where(a => a.Activiteit.Id == act.Id).Include(i => i.Activiteit).Include(t => t.Gebruiker).ToList(); foreach (GebruikerActiviteit geb in gebruikerActiviteits) { if (geb.Activiteit.Id == act.Id) { if (geb.Gebruiker != null) { gebruikersAct.Add(geb.Gebruiker.Id); } act.GebruikersApi.Add(geb.Gebruiker); } } //_gebruikerActiviteit.Where(a => a.Activiteit.Id == act.Id).Include(i => i.Activiteit).Include(t => t.Gebruiker).ToList().ForEach(t => //{ // if (t.Gebruiker.IdApi != 0) // { // gebruikersAct.Add(t.Gebruiker.IdApi); // } // else // { // if(t.Activiteit.Id == t.Activiteit.Id) // gebruikersAct.Add(t.Gebruiker.Id); // } //}); hulpList.Add(act); Activiteit hulpact = act; // hulpList.Add(hulpact); // hulpact = null; }); alleActiviteitsen.Clear(); foreach (Activiteit a in hulpList) { List <int> hulpints = new List <int>(); foreach (Gebruiker gebruiker in a.GebruikersApi) { if (gebruiker != null) { hulpints.Add(gebruiker.Id); } } a.GebruikersVoorActiviteit = hulpints; alleActiviteitsen.Add(a); hulpints.Clear(); } return(alleActiviteitsen); }
public RoosterItem(Activiteit activiteit, Begeleider begeleider, DateTime datum, TimeSpan startTijd, TimeSpan eindTijd) { this.activiteit = activiteit; this.begeleider = begeleider; this.datum = datum; this.startTijd = startTijd; this.eindTijd = eindTijd; }
public IActionResult AddActiviteit([FromBody] Activiteit activiteit) { _context.Activiteiten.Add(activiteit); _context.SaveChanges(); return(Ok()); }
public ActionResult <Activiteit> GetBy(int id) { Activiteit l = _activiteitRepository.GetBy(id); if (l == null) { return(NotFound("De activiteit kon niet worden gevonden")); } return(l); }
public Activiteit GetBy(int id) { Activiteit act = _activiteiten.SingleOrDefault(s => s.Id == id); if (act != null) { act.GebruikersApi = new List <Gebruiker>(); List <Gebruiker> geb = new List <Gebruiker>(); try { _gebruikerActiviteit.Where(a => a.Activiteit == act).Include(i => i.Activiteit).Include(t => t.Gebruiker).ToList().ForEach(t => { act.GebruikersVoorActiviteit = new List <int>(); //Gebruiker gebruiker = new Gebruiker(t.Gebruiker.Voornaam, t.Gebruiker.Naam, t.Gebruiker.Straatnaam, t.Gebruiker.Huisnummer, t.Gebruiker.Busnummer, t.Gebruiker.Postcode, t.Gebruiker.Stad, t.Gebruiker.Telefoonnummer, t.Gebruiker.Email, t.Gebruiker.GeboorteDatum, t.Gebruiker.Geslacht, t.Gebruiker.Type); // Gebruiker gebruiker = _ // if (t.Id != 0) // gebruiker.Id = t.Id; // act.GebruikersApi.Add(gebruiker); // if (gebruiker.Id != 0) // act.GebruikersVoorActiviteit.Add(gebruiker.Id); // else if (t.Gebruiker.IdApi != 0) { //act.GebruikersVoorActiviteit.Add(t.Gebruiker.IdApi); geb.Add(t.Gebruiker); } else { //act.GebruikersVoorActiviteit.Add(t.Gebruiker.Id); geb.Add(t.Gebruiker); } act.GebruikersApi = geb; }); } catch (Exception e) { act = _activiteiten.SingleOrDefault(s => s.Id == id); return(act); } } // _activiteiten.SingleOrDefault(s => s.Id == id); // if (act != null) //List<int> ids = new List<int>(); //foreach(Gebruiker gebruiker in act.GebruikersApi) //{ // if (gebruiker.Id != 0) // ids.Add(gebruiker.Id); // else // ids.Add(gebruiker.IdApi); //} //act.GebruikersVoorActiviteit = ids; return(act); }
// pas de punt in het getal aan naar een komma // indien er geen komma is (geheel getal), plaats dan ',00' na het gehele getal // is nodig omdat er anders validatiefouten optreden (8,99 is geen engels getal) // Prijs is een varchar in de tabel en geen getal private static void NormalizePrijs(Activiteit activiteit) { if (activiteit.Prijs != null) { activiteit.Prijs = activiteit.Prijs.Replace('.', ','); if (!activiteit.Prijs.Contains(',')) { activiteit.Prijs += ",00"; } } }
public ActionResult <Activiteit> Delete(int id) { Activiteit activiteit = _activiteitRepository.GetBy(id); if (activiteit == null) { return(BadRequest("Activiteit kon niet worden gevonden!")); } _activiteitRepository.Delete(activiteit); return(activiteit); }
public ActionResult AddRoute2(string routeNaam, string activiteitenIds, int?boekId) { if (!boekId.HasValue) { return(RedirectToAction("Index")); } Route nieuweRoute = new Route(); nieuweRoute.EigenaarID = bs.GetUser(User.Identity.Name).Id; //DIT NOG VERANDEREN Boek boek = bs.GetBoekByID(boekId); if (boek == null) { return(RedirectToAction("Index")); } if (boek.EigenaarId != bs.GetUser(User.Identity.Name).Id) { return(RedirectToAction("Index")); } nieuweRoute.Boeken = new List <Models.OmgevingsBoek_Models.Boek>(); nieuweRoute.Boeken.Add(bs.GetBoekByID(boekId)); nieuweRoute.Naam = routeNaam; string[] idsSplit = activiteitenIds.Split(','); nieuweRoute.RouteLijst = new List <RouteListItem>(); foreach (string a in idsSplit) { int res; if (!int.TryParse(a, out res)) { continue; } Activiteit ac = bs.GetActiviteitById(res); if (ac == null) { continue; } if (!bs.IsActivityAccessibleByUser(ac.Id, User.Identity.Name)) { continue; } nieuweRoute.RouteLijst.Add(new RouteListItem() { Activiteit = ac }); } bs.InsertRoute(nieuweRoute); return(RedirectToAction("Boek", new { id = boekId })); }
public void Delete(Activiteit activiteit) { _activiteiten.Remove(activiteit); List <GebruikerActiviteit> verwijderen = _gebruikerActiviteit.ToList(); verwijderen.ForEach(a => { if (a.Activiteit == activiteit) { _gebruikerActiviteit.Remove(a); } }); SaveChanges(); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Naam,Omschrijving,Publicatiedatum,Uiterste_inschrijfdatum,Prijs,Max_inschrijvingen,Id_ontmoetingsplaats,Activiteitendatum,Beginuur,Einduur")] Activiteit activiteit) { // mag de huidige gebruiker (indien gekend) deze gegevens zien // als het resultaat null is, mag hij de gegevens zien // als het resultaat niet null is, toon dan de gepaste pagina (login of unauthorized) IActionResult actionResult = CredentialBeheerder.CheckIfAllowed(_role, TempData, _context);; if (actionResult != null) { return(actionResult); } // is de doorgegeven id gelijk aan de id van de activiteit if (id != activiteit.Id) { return(NotFound()); } // zijn er geen validatie fouten // pas dan de gewijzigde activiteit aan in de db if (ModelState.IsValid) { try { // punt in getal (Engels getal) vervangen door komma NormalizePrijs(activiteit); _context.Update(activiteit); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActiviteitExists(activiteit.Id)) { return(NotFound()); } else { throw; } } // toon de lijst met activiteiten return(RedirectToAction(nameof(Index))); } // indien hier was er een fout met de validatie // vul de select lijst op met de naam van de ontmoetingsplaatsen ViewData["Id_ontmoetingsplaats"] = new SelectList(_context.Ontmoetingsplaatsen, "Id", "Plaatsnaam", activiteit.Id_ontmoetingsplaats); // blijf op de huidige pagina return(View(activiteit)); }
public IActionResult UpdateActiviteit([FromRoute] int id, [FromBody] Activiteit activiteit) { var activiteitToUpdate = _context.Activiteiten.Find(id); if (activiteitToUpdate == null) { return(NotFound("Activiteit met id '" + id + "' niet gevonden.")); } activiteitToUpdate.updateActiviteit(activiteit); _context.SaveChanges(); return(Ok()); }
public String HardDeleteActiviteit(List <int> ActiviteitenToDelete, int vanaf, int desc, int?filter) { if (!User.IsInRole("SuperAdministrator")) { return("fail"); } foreach (int activiteit in ActiviteitenToDelete) { Activiteit a = bs.GetActiviteitByIdAdmin(activiteit); if (a == null) { return("fail"); } bs.DeleteActiviteit(a); } return("ok"); }
public ActionResult <Activiteit> Post(ActiviteitDTO DTO) { try { List <Gebruiker> gebruikers = new List <Gebruiker>(); Boolean GebruikerNietGevonden = false; int GebruikerNietGevondenId = 0; //DTO.GebruikerIds.ForEach(GebruikerId => //{ // Gebruiker gebruiker = _gebruikerRepository.GetBy(GebruikerId); // if (gebruiker == null) // { // GebruikerNietGevonden = true; // GebruikerNietGevondenId = GebruikerId; // } // else // { // GebruikersVoorActiviteit.Add((Gebruiker)gebruiker); // } //}); //if (GebruikerNietGevonden) //{ // return BadRequest("Gebruiker met id " + GebruikerNietGevondenId + " kon niet worden gevonden!"); //} if (DTO.GebruikersVoorActiviteit != null) { foreach (int i in DTO.GebruikersVoorActiviteit) { gebruikers.Add(_gebruikerRepository.GetByApiId(i)); } } Activiteit l = new Activiteit(DateTime.Parse(DTO.StartDatum), gebruikers, DateTime.Parse(DTO.EindDatum), DTO.Naam, DTO.Type, DTO.MaxAantalGebruikers, DTO.Straat, DTO.Huisnr, DTO.Postcode, DTO.Stad, DTO.Startuur, DTO.Email, DTO.Telefoonnummer); l.GebruikersVoorActiviteit = DTO.GebruikersVoorActiviteit; _activiteitRepository.Add(l); _activiteitRepository.SaveChanges(); return(l); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (!User.Identity.IsAuthenticated) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } Activiteit activiteit = db.Activiteits.Find(id); if (activiteit == null) { return(HttpNotFound()); } return(View(activiteit)); }
public void EditShare(string Username, int Id, string Type, bool IsGedeeld) { if (!ModelState.IsValid) { return; } ApplicationUser user = bs.GetUser(Username); if (user == null) { return; } if (Type.ToLower() == "activiteit") { Activiteit a = bs.GetActiviteitById((int)Id); if (a == null) { return; } if (a.Eigenaar.UserName != User.Identity.Name) { return; } bs.addUserToActiviteitShareList(a.Id, user.UserName, IsGedeeld); } else if (Type.ToLower() == "boek") { Boek b = bs.GetBoekByID((int)Id); if (b == null) { return; } if (b.Eigenaar.UserName != User.Identity.Name) { return; } bs.addUserToBoekShareList(b.Id, user.UserName, IsGedeeld); } else { return; } }
public ActionResult Activiteit(int?Id, int?boekId) { if (!Id.HasValue) { return(RedirectToAction("Index")); } Activiteit activiteit = bs.GetActiviteitById((int)Id); if (activiteit == null) { return(RedirectToAction("Index")); } if (!bs.IsActivityAccessibleByUser((int)Id, User.Identity.Name)) { return(RedirectToAction("Index")); } ViewBag.boekId = boekId; return(View(activiteit)); }
public ActionResult GetActiviteit(int?Id) { if (!Id.HasValue) { return(RedirectToAction("Index")); } Activiteit a = bs.GetActiviteitById((int)Id); if (a == null) { return(HttpNotFound("Onbestaande Activiteit")); } if (a.Eigenaar.UserName != User.Identity.Name) { return(HttpNotFound("Geen toegang tot deze activiteit")); } return(Json(JsonConvert.SerializeObject(a), JsonRequestBehavior.AllowGet)); }
public String DeleteActiviteit(List <int> ActiviteitenToDelete, int vanaf, int desc, int?filter) { if (!User.IsInRole("SuperAdministrator") && !User.IsInRole("Administrator")) { return("fail"); } //TODO: ervoor zorgen dat lege gebruiker ook kan verwijderd worden. foreach (int activiteit in ActiviteitenToDelete) { Activiteit a = bs.GetActiviteitByIdAdmin(activiteit); if (a == null) { return("fail"); } bs.DeleteActiviteitSoft(a); } return("ok"); }
public QueryFeedback VoorschitenVoorHuisgenoten(int[] mensen, Activiteit activiteit) { QueryFeedback feedback = new QueryFeedback(); int aantalPersonenVoorVoorschieten = mensen.Length - 1; for (int i = 0; i <= aantalPersonenVoorVoorschieten; i++) { activiteit.TegenGebruiker = mensen[i]; feedback = _gebruikerRepo.VoegActifiteitToe(activiteit); if (!feedback.Gelukt) { return(feedback); } } return(feedback); }
public ActionResult Create([Bind(Include = "activiteit_id,naam,beschrijving,evenement,begintijd,eindtijd,evenement_beheerder")] Activiteit activiteit) { if (ModelState.IsValid) { if (db.Evenements.Find(activiteit.evenement).EvenementBeheerders.Count() > 1) { TempData["wijziging"] = GenerateWijziging(activiteit, 1); return(RedirectToAction("Create", "Wijzigingen", null)); } else { db.Activiteits.Add(activiteit); db.SaveChanges(); } return(RedirectToAction("Dashboard", "Evenementen", new { id = activiteit.evenement })); } return(View(activiteit)); }
private Wijziging GenerateWijziging(Activiteit activiteit, int type) { if (User.Identity.IsAuthenticated) { int userId = Convert.ToInt32(User.Identity.GetUserId()); int beheerder = db.EvenementBeheerders.Where(e => e.evenement == activiteit.evenement).First(b => b.beheerder == userId).evenement_beheerder_id; Wijziging change = new Wijziging { beheerder = beheerder, type = type, jsonClassType = activiteit.GetType().ToString(), jsonData = new JavaScriptSerializer().Serialize(activiteit) }; return(change); } else { throw (new Exception("No logon found")); } }
public QueryFeedback VoegActifiteitToe(Activiteit activiteit) { QueryFeedback feedback = new QueryFeedback(); try { using (SqlConnection conn = new SqlConnection(sqlcon.connectionstring())) { using (SqlCommand cmd = new SqlCommand()) { string qry = "Insert INTO [dbo].[Table_Activiteit] Values(@ingelogdegebruiker,@studentenhuisid,@datum,@beschrijving,@bedrag,@tegengebruiker)"; cmd.CommandText = qry; cmd.Parameters.AddWithValue("@ingelogdegebruiker", activiteit.IngelogdeGebruiker); cmd.Parameters.AddWithValue("@studentenhuisid", activiteit.StudentenhuisID); cmd.Parameters.AddWithValue("@datum", activiteit.Datum); cmd.Parameters.AddWithValue("@beschrijving", activiteit.Beschrijving); cmd.Parameters.AddWithValue("@bedrag", activiteit.Bedrag); cmd.Parameters.AddWithValue("@tegengebruiker", activiteit.TegenGebruiker); cmd.Connection = conn; conn.Open(); cmd.ExecuteNonQuery(); feedback.Gelukt = true; return(feedback); } } } catch (Exception ex) { feedback.Gelukt = false; feedback.Message = ex.Message; return(feedback); } }
public ActionResult DeleteActiviteit(int?Id, int?boekId) { //geef hier het boekid mee zodat de gebruiker terug naar zijn boek kan aub. if (!Id.HasValue) { return(RedirectToAction("Index")); } Activiteit activiteit = bs.GetActiviteitById((int)Id); if (activiteit == null) { return(RedirectToAction("Index")); } if (activiteit.EigenaarId != bs.GetUser(User.Identity.Name).Id) { return(RedirectToAction("Index")); } bs.DeleteActiviteitSoft(activiteit); return(RedirectToAction("Boek", new { id = boekId })); }
public ActionResult Details(int?id, int?boekId) { if (!id.HasValue) { return(RedirectToAction("Index", "Home")); } Activiteit activ = bs.GetActiviteitById((int)id); Session["stap3"] = activ.Naam; Session["url3"] = "../Activiteiten/Details/" + activ.Id; ViewBag.stap1 = Session["stap1"]; ViewBag.url1 = Session["url1"]; ViewBag.stap2 = Session["stap2"]; ViewBag.url2 = Session["url2"]; ViewBag.stap3 = Session["stap3"]; ViewBag.url3 = Session["url3"]; ViewBag.boekId = boekId; return(View(activ)); }