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 Route InsertRoute(Route entity) { return repoRoute.Insert(entity); }