Esempio n. 1
0
        public PriceModel[] GetCopy()
        {
            var copiedPrices = new PriceModel[_prices.Count];

            _prices.Values.CopyTo(copiedPrices, 0);
            return(copiedPrices);
        }
        public PriceModel GetlPriceById(int id)
        {
            PriceModel singlePriceForEachVehcle = GetAllPrice()
                                                  .FirstOrDefault(x => x.Id == id);

            return(singlePriceForEachVehcle);
        }
Esempio n. 3
0
        public ActionResult Perfume_Details(int PerfumeID, int brandID = 0, String type = "", int currentPageIndex = 1)
        {
            String Message = "";
            var    perfume = db.Tbl_Perfume.Where(a => a.Perfume_ID == PerfumeID).SingleOrDefault();

            if (perfume != null)
            {
                Rep_Perfume rep_Perfume = new Rep_Perfume();
                var         seasons     = rep_Perfume.Get_PerfumeSeasons(PerfumeID);
                ViewBag.seasonCount = seasons.Count();

                PriceModel prices = new PriceModel();
                prices = InitDropdownLists(PerfumeID);
                ViewBag.cologne_price            = prices.ColognePrice;
                ViewBag.handySample_price        = prices.HandySamplePrice;
                ViewBag.companySample_price      = prices.CompanySamplePrice;
                ViewBag.cologne_weightList       = prices.CologneWeightList;
                ViewBag.handySample_weightList   = prices.HandySampleWeightList;
                ViewBag.companySample_weightList = prices.CompanySampleWeightList;

                string returnURl = "/Perfumes/" + brandID + "/" + type + "/" + currentPageIndex;
                ViewBag.returnURL = returnURl;

                return(View(perfume));
            }
            else
            {
                Message = "perfume with ID" + PerfumeID + "not found.";
                log.addLog(Message, "AddCart", "Cart", logStatus.EventLog);
                ViewBag.Error = "محصول پیدا نشد، لطفا دوباره تلاش کنید.";
                return(RedirectToAction("Index", "Home"));
            }
        }
Esempio n. 4
0
         public PriceListViewModels()
         {
             this._view = new TViewType();
 
             this._modelPriceListModel = new PriceListModel();
             this.PriceListObservableCollection = new ObservableCollection<PriceList>(this._modelPriceListModel.GetService());
 
             this._modelPriceModel = new PriceModel();
             this.PriceObservableCollection = new ObservableCollection<Price>(this._modelPriceModel.GetPrice());
 
             this._modelNewServInPriceListModel = new NewServInPriceListModel();
             this.NewServObServableCollection = new ObservableCollection<NewServInPriceList>(this._modelNewServInPriceListModel.GetNewServ());
             this.CommandSave = new RelayCommand(o => this.OKRun());
 
 
             // присваиваем collview observable collection 
             collview = (CollectionView)CollectionViewSource.GetDefaultView(NewServObServableCollection);
 
             // задаем начальные значения для DateTimePicker
             _dateTimeBeginPriceList = DateTime.Today.AddDays(-1);
             _dateTimeEndPriceList =  new DateTime(2016, 05, 28);
 
             _displayRadioButton = true;
 
             _contentButtonDisplaySearch = "Найти";
                     
             this._view.SetDataContext(this);
             this._view.ShowIView();
         }
Esempio n. 5
0
    public PriceModel GetPurchasedLevel(int level)
    {
        PriceModel foundPriceModel    = null;
        bool       foundPurchasedItem = false;
        int        itPurchase         = 0;

        while (!foundPurchasedItem && itPurchase < Prices.Count)
        {
            PriceModel priceModel = Prices [itPurchase];
            if (priceModel.Level == level)
            {
                // copy found price model
                foundPriceModel       = new PriceModel();
                foundPriceModel.Level = priceModel.Level;
                foundPriceModel.Price = priceModel.Price;

                foundPurchasedItem = true;
            }
            itPurchase++;
        }

        if (foundPurchasedItem)
        {
            return(foundPriceModel);
        }
        else
        {
            // when not found price model it means it's the highest
            foundPriceModel       = new PriceModel();
            foundPriceModel.Level = -1;
            foundPriceModel.Price = -1;
            return(foundPriceModel);
        }
    }
Esempio n. 6
0
        public PriceModel GetData(string priceID)
        {
            PriceModel result = null;
            var        sSql   = @"
                SELECT
                    PriceID, PriceName
                FROM
                    Price
                WHERE
                    PriceID = @PriceID ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@PriceID", priceID);
                    conn.Open();
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (!dr.HasRows)
                        {
                            return(null);
                        }
                        result = new PriceModel
                        {
                            PriceID   = dr["PriceID"].ToString(),
                            PriceName = dr["PriceName"].ToString()
                        };
                    }
                }
            return(result);
        }
Esempio n. 7
0
        public void Return_100_by_default(decimal distance, decimal weight)
        {
            PriceModel result = _priceHandler.GetPrice(distance, weight);

            //Assert price 100
            Assert.Equal(100, result.Price);
        }
Esempio n. 8
0
        private async Task <ReturnPrice> GetPriceAzulAsync(string productId, string storeId, bool customerRegistered)
        {
            PriceModel priceModel = await new RequestService <PriceModel>(httpClient).SendResquest($"https://dev.apipmenos.com/price/v1/" + productId + "?subsidiaryId=" + storeId, "vhubPbOuqb7X5ZEuflnJN1c3GlR03K2x4KzAt6d1");
            Decimal    SalePrice;

            if (customerRegistered)
            {
                SalePrice = Decimal.Parse(priceModel.price.everBluePrice);
            }
            else
            {
                SalePrice = Decimal.Parse(priceModel.price.salePrice);
            }


            ReturnPrice returnPrice = new ReturnPrice
            {
                DiscountType       = DiscountType.Azul,
                MaximumPrice       = Decimal.Parse(priceModel.price.salePrice),
                PercentageDiscount = Math.Round(((Decimal.Parse(priceModel.price.salePrice) - SalePrice) / Decimal.Parse(priceModel.price.salePrice)) * 100, 2),
                ProductId          = int.Parse(productId),
                SalePrice          = SalePrice
            };

            return(returnPrice);
        }
Esempio n. 9
0
        public IActionResult PriceList()
        {
            var prices = new List <PriceModel>();

            var serviceOne = new PriceModel {
                Service = "Oil Change",
                Info    = "Changing your oil",
                Price   = "$20"
            };
            var serviceTwo = new PriceModel {
                Service = "Fix Toilet",
                Info    = "Unclog your nastiness",
                Price   = "$30"
            };
            var serviceThree = new PriceModel {
                Service = "Mow Lawn",
                Info    = "What is this a rainforest?",
                Price   = "$50"
            };

            prices.Add(serviceOne);
            prices.Add(serviceTwo);
            prices.Add(serviceThree);

            return(View(prices));
        }
Esempio n. 10
0
        public string EstimatePrice(PriceModel priceModel, PrintType pType)
        {
            string result = string.Empty;

            try
            {
                switch (pType)
                {
                case PrintType.printOnScreen:
                    _printEstimationService.PrintOnScreen(priceModel, out result);
                    break;

                case PrintType.printToPaper:
                    _printEstimationService.PrintToPaper(priceModel, out result);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //Log Exception
            }
            return(result);
        }
Esempio n. 11
0
        // GETHOURANDDAYPRICE
        // extracts a format like "5,00 € / 15,00 €"
        private static PriceModel GetHourAndDayPrice(string input)
        {
            PriceModel model = new PriceModel();

            // split in half
            string[] halfs = input.Split('/');

            string pricePerHourStr = halfs [0]
                                     .Replace("€", "")
                                     .Replace("EUR", "")
                                     .Replace(",", ".")
                                     .Trim();

            string pricePerDayStr = halfs [1]
                                    .Replace("€", "")
                                    .Replace("EUR", "")
                                    .Replace(",", ".")
                                    .Trim();

            // check for format "2,50 € / Tag"
            if (halfs [1].ToLower().Contains("tag"))
            {
                model.FullDay = Convert.ToDouble(pricePerHourStr);
            }
            else
            {
                model.PerHour = new PerHourModel(1, Convert.ToDouble(pricePerHourStr));
                model.FullDay = Convert.ToDouble(pricePerDayStr);
            }

            return(model);
        }
Esempio n. 12
0
        /// <summary>
        /// Sets discount price for the first variation with a price
        /// </summary>
        /// <param name="findProduct"></param>
        /// <param name="content"></param>
        /// <param name="market"></param>
        public static void SetPriceData(this FindProduct findProduct, List <VariationContent> content, IMarket market)
        {
            VariationContent variation = null;

            if (content.Any())
            {
                foreach (var item in content)
                {
                    var price = item.GetPrice(market);
                    if (price != null)
                    {
                        variation = item;
                        break;
                    }
                }
            }

            if (variation == null)
            {
                return;
            }

            PriceModel priceModel = variation.GetPriceModel(market);

            findProduct.DefaultPrice       = priceModel.DefaultPrice.UnitPrice.ToString();
            findProduct.DefaultPriceAmount = content.GetDefaultPriceAmountWholeNumber(market);

            DiscountPrice discountPrice = priceModel.DiscountPrice;

            findProduct.DiscountedPriceAmount = (double)discountPrice.GetDiscountPriceWithCheck();
            findProduct.DiscountedPrice       = discountPrice.GetDiscountDisplayPriceWithCheck();

            findProduct.CustomerClubPriceAmount = (double)priceModel.CustomerClubPrice.GetPriceAmountSafe();
            findProduct.CustomerClubPrice       = priceModel.CustomerClubPrice.GetPriceAmountStringSafe();
        }
        public PriceModel GetPriceModel(ParkingLot lot)
        {
            PriceModel priceModel = null;

            // Get current time in the Parking Lot Time zone
            DateTime now = lot.ConvertToLocalTime(DateTime.Now, TimeZoneInfo.Local);

            DateTime resDate   = new DateTime(now.Year, now.Month, now.Day);
            int      year      = resDate.Year;
            int      dayofWeek = (int)resDate.DayOfWeek;

            dayofWeek = dayofWeek == 0 ? 7 : dayofWeek; // Convert Sunday to 7
            int hour = now.Hour;

            string sql = $"SELECT * FROM dbo.pricemodel p WHERE p.LotId = '{lot.Id}'" +
                         $" AND DATEFROMPARTS({year}, p.StartMonth, p.StartDate) <= @resDate" +
                         $" AND DATEFROMPARTS({year}, p.EndMonth, p.EndDate) >= @resDate" +
                         $" AND p.StartDayofWeek <= {dayofWeek} AND p.EndDayofWeek >= {dayofWeek}" +
                         $" AND p.StartTime <= {hour} AND p.EndTime >= {hour}" +
                         $" ORDER BY DATEDIFF(d, DATEFROMPARTS({year}, p.StartMonth, p.StartDate), @resDate)" +
                         $", {dayofWeek} - p.StartDayofWeek, {hour} - p.StartTime";

            using (var context = new MobileServiceContext())
            {
                //priceModel = context.PriceModels.SqlQuery(sql, new SqlParameter("@resDate", resDate)).FirstOrDefault();
                priceModel = context.Database.SqlQuery <PriceModel>(sql, new SqlParameter("@resDate", resDate)).FirstOrDefault();
            }

            return(priceModel);
        }
Esempio n. 14
0
        public IActionResult Pricelist()
        {
            var prices = new List <PriceModel>();

            var serviceOne = new PriceModel
            {
                Service = "Oil Change",
                Info    = "Changing your oil",
                Price   = "$20"
            };

            var serviceTwo = new PriceModel
            {
                Service = "Tune-up",
                Info    = "Tuning up your engine",
                Price   = "$30"
            };

            var serviceThree = new PriceModel
            {
                Service = "Mow Lawn",
                Info    = "Mowing your lawn",
                Price   = "$50"
            };

            prices.Add(serviceOne);
            prices.Add(serviceTwo);
            prices.Add(serviceThree);

            return(View(prices));
        }
Esempio n. 15
0
        public static MessageResult AddPrice(PriceModel price, string AddedBy)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(DBConn))
                {
                    querry = $@"Update Price set Status = @Status where ProductID = @ProductID 
                            Insert into price(ID,ProductID,Price,AddedBy,DateAdded)
                            values(@ID,@ProductID,@Price,@AddedBy,@DateAdded)";
                    using (SqlCommand cmd = new SqlCommand(querry, conn))
                    {
                        conn.Open();
                        cmd.Parameters.AddWithValue("@ID", Guid.NewGuid());
                        cmd.Parameters.AddWithValue("@ProductID", price.ProductID);
                        //cmd.Parameters.AddWithValue("@ZoneID", price.ZoneID);
                        cmd.Parameters.AddWithValue("@Price", price.Price);
                        cmd.Parameters.AddWithValue("@AddedBy", AddedBy);
                        cmd.Parameters.AddWithValue("@Status", 0);
                        cmd.Parameters.AddWithValue("@DateAdded", DateTime.Now);

                        cmd.ExecuteScalar();
                        mes.Status  = "success";
                        mes.Message = "Price added successfully";
                    }
                }
            }catch (Exception e)
            {
                mes.Status = "info";
                mes.Status = "Failed! reload and try again later";
            }

            return(mes);
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            string     json  = "{\"Date\":\"2018-03-23\",\"Requests\":\"24,992\",\"Price\":\"95.96\"}";
            PriceModel value = JsonConvert.DeserializeObject <PriceModel>(json);

            Console.ReadLine();
        }
Esempio n. 17
0
        private double MoneyAtStroke(PriceModel model, double startPrice, double strike, OptionType type, int optSide, int periods, int volume)
        {
            var price = startPrice;

            for (var i = 0; i < periods; i++)
            {
                var delta = model.GetRandomDelta();
                var sign  = rand.Next(2) > 0 ? 1 : -1;
                price += delta * sign;
                if (type == OptionType.Touch)
                {
                    if (optSide > 0 && price >= strike)
                    {
                        return(volume);
                    }
                    if (optSide < 0 && price <= strike)
                    {
                        return(volume);
                    }
                }
            }
            if (optSide > 0 && price >= strike)
            {
                return(volume * (price - strike));
            }
            if (optSide < 0 && price <= strike)
            {
                return(volume * (strike - price));
            }
            return(0);
        }
Esempio n. 18
0
        public void Return_75_when_distance_is_overOrEqual_5_and_weight_is_under_10(decimal distance, decimal weight)
        {
            PriceModel result = _priceHandler.GetPrice(distance, weight);

            //Assert price 75
            Assert.Equal(75, result.Price);
        }
Esempio n. 19
0
        public void Return_50_when_distance_is_under_5_and_weight_is_moreThan_or_equal_10(decimal distance, decimal weight)
        {
            PriceModel result = _priceHandler.GetPrice(distance, weight);

            //Assert price 50
            Assert.Equal(50, result.Price);
        }
Esempio n. 20
0
        public void Return_free_when_distance_is_under_5_and_weight_is_under_10(decimal distance, decimal weight)
        {
            PriceModel result = _priceHandler.GetPrice(distance, weight);

            //Assert price 0
            Assert.Equal(0, result.Price);
        }
Esempio n. 21
0
    void UpdateCurrentPrice()
    {
        // Set the price if it has multiple price count
        if (ShopItem.Prices.Count > 1)
        {
            int currentItemLevel = GameSaveManager.Instance.GetPurchaseLevel(ShopItem.ID);
            _CurrentPriceModel = ShopItem.GetPurchasedLevel(currentItemLevel + 1);

            // reached highest level
            if (_CurrentPriceModel.Level == -1)
            {
//				_MaxedOut = false;
            }

            // set price
            ItemPrice.text = _CurrentPriceModel.Price.ToString();
        }
        else
        {
            // cek udah beli aja karena cuma ada 1 level

            _CurrentPriceModel = ShopItem.GetPurchasedLevel(0);

            bool purchased = GameSaveManager.Instance.CheckPurchase(ShopItem.ID);
            if (purchased)
            {
                ItemPrice.text = "";
            }
            else
            {
                ItemPrice.text = _CurrentPriceModel.Price.ToString();
            }
        }
    }
Esempio n. 22
0
        public async Task <List <PriceModel> > GetPricesGame(int gameId)
        {
            try
            {
                var prices = await _context.Prices.Where(_ => _.GameId == gameId).ToListAsync();

                var result = new List <PriceModel>();

                prices.ForEach(item =>
                {
                    var price = new PriceModel
                    {
                        Name  = item.Name,
                        Value = Convert.ToDouble(item.Value)
                    };

                    result.Add(price);
                });

                return(result);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
Esempio n. 23
0
        public PriceModel Calculate(PriceModel input)
        {
            double discount = _context.Prices.Where(s => s.userType == input.userType).Select(s => s.discount).FirstOrDefault();

            input.total = (input.pricePerGm * input.weight) * (100 - discount) / 100;

            return(input);
        }
Esempio n. 24
0
 public async Task <bool> UpdatePrice([FromBody] PriceModel price)
 {
     if (await _clinicContract.UpdatePrice(_mapper.Map <PriceModel, PricePOCO>(price)))
     {
         return(true);
     }
     return(false);
 }
        public void PricingModel_Should_Contain_3_Items()
        {
            var homeController = new HomeController();
            var pricingModel   = new PriceModel();

            Assert.NotNull(pricingModel);
            Assert.InRange(homeController.PriceModel.Pricings.Count, 3, 3);
        }
            public static PriceModel GetModel()
            {
                PriceModel priceModel = new PriceModel();

                priceModel.PriceLists = GetAllPriceLists();
                priceModel.Contacts   = GetContact();
                return(priceModel);
            }
        public string MakeReservation(Reservation resItem)
        {
            ReservationType rtype = ReservationType.GetType(resItem.Type);

            if (rtype == ReservationType.LTWeekly || rtype == ReservationType.LTWeeklyWorkHrs)
            {
                resItem.EndDate = resItem.StartDate.AddDays(7);
            }
            else if (rtype == ReservationType.LTMonthly || rtype == ReservationType.LTMonthlyWorkHrs)
            {
                resItem.EndDate = resItem.StartDate.AddDays(30);
            }
            else
            {
                resItem.EndDate = resItem.StartDate.AddDays(1);
            }

            resItem.EndDate = resItem.EndDate.AddSeconds(-1); // 12.59.59 PM Local time on the last day of reservation

            using (var context = new MobileServiceContext())
            {
                try
                {
                    ParkingLot parkingLot = context.ParkingLots.Find(resItem.LotId);

                    string sql = "SELECT COUNT(*) FROM Reservation rr WHERE rr.LotId = @lotid and @startDt <= rr.EndDate and @endDt >= rr.StartDate";

                    SqlParameter[] parms = new SqlParameter[]
                    {
                        new SqlParameter("@lotid", resItem.LotId),
                        new SqlParameter("@startDt", resItem.StartDate),
                        new SqlParameter("@endDt", resItem.EndDate),
                    };

                    int reserved = context.Database.SqlQuery <int>(sql, parms).FirstOrDefault();

                    if (reserved >= parkingLot.Capacity)
                    {
                        return("Parking not available for the selected date(s)");
                    }

                    PriceModel priceModel = context.PriceModels.Find(resItem.PriceModelId);
                    resItem.AdvancePaid = priceModel.GetAdvanceCharge(resItem.Type);

                    Utils.CreateStripeCharge(resItem.AdvancePaid.Value, parkingLot.Name, resItem.ConfNumAdvance);

                    parkingLot.Reserved++;
                    context.Reservations.Add(resItem);
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ServerUtils.BuildException(ex);
                }
            }

            return(null);
        }
Esempio n. 28
0
    void UpdateCurrentPrice()
    {
        bool eligibleToBuy = false;

        // Set the price if it has multiple price count
        if (ShopItem.Prices.Count > 1)
        {
            int currentItemLevel = GameSaveManager.Instance.GetPurchaseLevel(ShopItem.ID);
            _CurrentPriceModel = ShopItem.GetPurchasedLevel(currentItemLevel + 1);

            // reached highest level
            if (_CurrentPriceModel.Level <= -1)
            {
                eligibleToBuy  = false;
                PriceText.text = "";
            }
            else
            {
                eligibleToBuy = true;
                // set price
                PriceText.text = _CurrentPriceModel.Price.ToString();
            }
        }
        else
        {
            // cek already purchased single priced (not upgrade-able item)

            _CurrentPriceModel = ShopItem.GetPurchasedLevel(0);

            bool purchased = GameSaveManager.Instance.CheckPurchase(ShopItem.ID);
            if (purchased)
            {
                eligibleToBuy  = false;
                PriceText.text = "";
            }
            else
            {
                eligibleToBuy  = true;
                PriceText.text = _CurrentPriceModel.Price.ToString();
            }
        }

        // check price
        if (eligibleToBuy)
        {
            int currentCoin = GameSaveManager.Instance.GetCoins();
            if (currentCoin >= _CurrentPriceModel.Price)
            {
                eligibleToBuy = true;
            }
            else
            {
                eligibleToBuy = false;
            }
        }

        BuyButton.gameObject.SetActive(eligibleToBuy);
    }
Esempio n. 29
0
        public static PriceModel GetPriceModel(this VariationContent currentContent)
        {
            PriceModel priceModel = new PriceModel();

            priceModel.Price = GetPrice(currentContent);
            priceModel.DiscountDisplayPrice     = currentContent.GetDiscountDisplayPrice(currentContent.GetDefaultPrice());
            priceModel.CustomerClubDisplayPrice = currentContent.GetCustomerClubDisplayPrice();
            return(priceModel);
        }
Esempio n. 30
0
        protected virtual PriceModel GetPriceModel(VariationContent currentContent)
        {
            PriceModel priceModel = new PriceModel();

            priceModel.Price = GetPrice(currentContent);
            priceModel.DiscountDisplayPrice     = currentContent.GetDiscountDisplayPrice(currentContent.GetDefaultPrice());
            priceModel.CustomerClubDisplayPrice = currentContent.GetCustomerClubDisplayPrice();
            return(priceModel);
        }