コード例 #1
0
        private ReturnPrice GetPriceEncarte(ReturnPrice returnPrice, CustomerScore customerScore, long storeId)
        {
            MedalCode medalCode;

            if (customerScore.Score == null)
            {
                medalCode = MedalCode.NotRegistered;
            }
            else
            {
                medalCode = (MedalCode)int.Parse(customerScore.Score.Id);
            }

            PriceEncarte priceEncarte = _precoRepository.GetPriceEncarte(returnPrice.ProductId, storeId, medalCode);

            ReturnPrice price = new ReturnPrice();

            if (priceEncarte.SalePrice > 0)
            {
                price = new ReturnPrice
                {
                    ProductId          = returnPrice.ProductId,
                    SalePrice          = priceEncarte.SalePrice,
                    MaximumPrice       = returnPrice.SalePrice,
                    DiscountType       = DiscountType.Encarte,
                    PercentageDiscount = Math.Round(((returnPrice.SalePrice - priceEncarte.SalePrice) / returnPrice.SalePrice) * 100, 2)
                };
            }

            return(price);
        }
コード例 #2
0
        public PriceEncarte GetPriceEncarte(long productId, long storeId, MedalCode medalCode)
        {
            var sql = PriceScripts.SELECT_PRECO_ENCARTE_POR_FILIAL_E_CODIGO;

            using (var connection = new SqlConnection(_connectionString))
            {
                var parameters = new DynamicParameters();

                parameters.Add("@StoreId", storeId, DbType.Int32, ParameterDirection.Input);
                parameters.Add("@ProductId", productId, DbType.Int32, ParameterDirection.Input);
                parameters.Add("@MedalCode", medalCode, DbType.Int32, ParameterDirection.Input);

                PriceEncarte priceEncarte = connection.QueryFirstOrDefault <PriceEncarte>(sql, parameters);

                return(priceEncarte);
            }
        }