// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { OrganisedEvent.FestivalEvents = new List <FestivalEvent>(); if (string.IsNullOrEmpty(OrganisedEvent.EventName) || string.IsNullOrEmpty(OrganisedEvent.StartTime) || string.IsNullOrEmpty(OrganisedEvent.StartDate) || string.IsNullOrEmpty(OrganisedEvent.EndTime) || string.IsNullOrEmpty(OrganisedEvent.EndDate) || string.IsNullOrEmpty(OrganisedEvent.PreparationTime) || string.IsNullOrEmpty(OrganisedEvent.CleanUpTime)) { return(Page()); } _context.Events.Add(OrganisedEvent); _context.SaveChanges(); var festivalEvent = new FestivalEvent() { FestivalId = FestivalId, OrganisedEventId = OrganisedEvent.OrganisedEventId }; OrganisedEvent.FestivalEvents.Add(festivalEvent); await _context.SaveChangesAsync(); return(RedirectToPage("/Festivals/Details", new { id = Request.Query["id"] })); }
//TODO: CART Repository //todo: add item to list via constr public List <OrderItem> Additem(int itemid, int aantal, string Question, FestivalEvent festivalEvent, int prijs) { int Orderid = -1; List <OrderItem> items = new List <OrderItem>(); OrderItem items1 = new OrderItem(itemid, Orderid, aantal, Question, festivalEvent, prijs); items.Add(items1); return(items); }
//TODO: Action AddtoCart parameters in eventid, userid enzo public ActionResult AddToCart(int eventid, int userid, string Question, int aantal, int prijs) { // om totaal te berkenen int totaal = 0; CartModel cartModel = new CartModel(); //TODO: If session != null => Model = session if (Session["CurrentWishlist"] != null) { cartModel = Session["CurrentWishlist"] as CartModel; //TODO: Session oude orderitems in een lijst List <OrderItem> Old = new List <OrderItem>(); Old = cartModel.AllOrderitems; //TODO: New lijst van orderitems aanmaken List <OrderItem> New = new List <OrderItem>(); //TODO: Get current event via Id FestivalEvent curentevent = cartRepository.GetbesteldEvent(eventid); //TODO: Item toevoegen aan de niewe lijs New = cartRepository.Additem(eventid, aantal, Question, curentevent, prijs); //TODO: OUDE EN NIEWE list mixen New.AddRange(Old); //TODO: SUBTOTAL berekenen foreach item en totaal alles foreach (var item in New) { int subtotaal = (item.Aantal * item.Prijs); totaal = totaal + subtotaal; } //TODO: return Model met totaal eb list items cartModel.totaal = totaal; cartModel.AllOrderitems = New; //TODO: Session == model Session["CurrentWishlist"] = cartModel; return(View(cartModel)); } //TODO: If session == null //todo:get event FestivalEvent eventi = cartRepository.GetbesteldEvent(eventid); //todo: list all orderitems = additem to list via constr met Objrct orderitemsdetails cartModel.AllOrderitems = cartRepository.Additem(eventid, aantal, Question, eventi, prijs); //todo: list items voor db zonder item event cartModel.AllOrderdetailtodb = cartRepository.Additemzonderevent(eventid, aantal, Question, prijs); //todo: totaal berekenen foreach (var item in cartModel.AllOrderitems) { int subtotaal = (item.Aantal * item.Prijs); totaal = totaal + subtotaal; } cartModel.totaal = totaal; //todo: session = cartmodel Session["CurrentWishlist"] = cartModel; return(View(cartModel)); }
//todo: getevnt met id in public FestivalEvent GetbesteldEvent(int eventid) { FestivalEvent talk = db.FestivalEvent.Where(a => a.ID == eventid).SingleOrDefault(); return(talk); }