public IActionResult OnPostDiscount() { List <Offer> offers = OfferRepository.AllOffers(); OItems = ItemsInCart.GetOrderedWares(); if (Offer.Code != 0) { foreach (var o in offers) { if (o.Code == Offer.Code) { discount.UseOffer(o); View = true; Wrong = false; } else { View = false; Wrong = true; } } } return(Page()); }
//public double CalculateTotalPrice() //{ // double totalPrice = 0; // foreach (OrderItem w in _waresInCart) // { // totalPrice = totalPrice + w.Ware.Price * w.Amount; // } // return totalPrice; //} public double CalculateTotalPrice(int?code) { List <Offer> offers = OfferRepository.AllOffers(); double totalPrice = 0; foreach (OrderItem w in _waresInCart) { totalPrice = totalPrice + w.Ware.Price * w.Amount; if (code != null) { foreach (var o in offers) { if (o.Code == code) { totalPrice = totalPrice * (1 - o.Discount); } } } else { code = 0; } } return(totalPrice); }
public IActionResult OnGet() { Wares = _wareRepo.AllWares(); Orders = _orderRepo.AllOrders(); Offers = _offerRepo.AllOffers(); if (_loginService.GetLoggedInUser() != null) { if (_loginService.GetLoggedInUser().UserType == UserTypes.Admin) { Users = UserRepo.GetAllUsers(); return(Page()); } } return(RedirectToPage("/Index")); }