Пример #1
0
        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());
        }
Пример #2
0
        //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);
        }
Пример #3
0
        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"));
        }