Exemplo n.º 1
0
        public async Task <int> AddPriceOverviewAsync(PriceOverviewAddModel priceOverview)
        {
            string query = $@"INSERT INTO PriceOverview 
                        (Price, PriceFormat, FinalPrice, FinalPriceFormat, CurrencyId, DiscountPercentage)
                    OUTPUT INSERTED.PriceOverviewId
                        VALUES(@Price, @PriceFormat, @FinalPrice, @FinalPriceFormat, @CurrencyId, @DiscountPercentage)
                    ";

            return(await SaveDataAsync(query, priceOverview));
        }
Exemplo n.º 2
0
        public bool ComparePriceIsSame(PriceOverviewModel priceOverviewDB, PriceOverviewAddModel currentPriceOverview)
        {
            // check if the base price is the same
            if (priceOverviewDB.Price == currentPriceOverview.Price)
            {
                // check if the base price is the same otherwise it means price has gone on to discount
                if (priceOverviewDB.FinalPrice == currentPriceOverview.FinalPrice)
                {
                    return(true);
                }

                return(false);
            }
            Console.WriteLine($"The base price has changed from {priceOverviewDB.Price} to {currentPriceOverview.Price}");

            return(false);
        }
Exemplo n.º 3
0
        public async Task <int> AddPriceOverview(PriceOverviewAddModel priceOverview)
        {
            var validator = DataValidatorHelper.Validate(priceOverview);


            if (validator.IsValid)
            {
                priceOverview.CurrencyId = await AddCurrency(priceOverview.Currency);


                return(await _gamedbAccess.AddPriceOverviewAsync(priceOverview));
            }


            Console.WriteLine($"Invalid Data from {nameof(PriceOverviewAddModel)}");
            validator.Errors.ForEach(e => Console.WriteLine(e));

            throw new Exception("Some data are invalid");
        }