Exemple #1
0
        protected override void EstablishContext()
        {
            base.EstablishContext();
            Rates.Add(CreateRate(currencyGuideAmount: "not-valid-int"));

            ScenarioExceptionsExpected = true;
        }
 private void UpdateRating(
     string teamCode,
     NibbleTeamRating rating,
     int week)
 {
     Utility.Announce($"    Updating rating for {teamCode}");
     if (Rates == null)
     {
         Rates = new Hashtable();
     }
     if (Rates.ContainsKey(teamCode))
     {
         var ratings   = (NibbleTeamRating[])Rates[teamCode];                  // get the array for the team
         var newRating = ratings[week - 2];
         newRating.Offence += rating.Offence;
         newRating.Defence += rating.Defence;
         ratings[week - 1]  = newRating;
         Rates[teamCode]    = ratings;
     }
     else
     {
         var ratings = new NibbleTeamRating[Season.Weeks];
         ratings[week - 1] = rating;
         Rates.Add(teamCode, ratings);
     }
 }
Exemple #3
0
        protected override void EstablishContext()
        {
            base.EstablishContext();
            Rates.Add(CreateRate(multiply: "not-valid-int"));

            ScenarioExceptionsExpected = true;
        }
Exemple #4
0
        private void LoadRates()
        {
            var rateValues = new List <RateValue>();
            var type       = typeof(Rates);
            var properties = type.GetRuntimeFields();

            foreach (var property in properties)
            {
                var code = property.Name.Substring(1, 3);
                rateValues.Add(new RateValue
                {
                    Code    = code,
                    TaxRate = (double)property.GetValue(exchangeRates.Rates)
                });
            }
            ;

            //names
            var rateNamesList = new List <RateName>();

            type       = typeof(RateNames);
            properties = type.GetRuntimeFields();

            foreach (var property in properties)
            {
                var code = property.Name.Substring(1, 3);
                rateNamesList.Add(new RateName
                {
                    Code = code,
                    Name = (string)property.GetValue(rateNames)
                });
            }

            Rates.Clear();

            List <Rate> rateList = joinList(rateValues, rateNamesList);

            var auxListRate = dataService.Get <Rate>(false);

            if (auxListRate.Count != 0)
            {
                dataService.DeleteAll <Rate>();
            }

            foreach (Rate property in rateList)
            {
                Rates.Add(new Rate
                {
                    Code    = property.Code,
                    TaxRate = (double)property.TaxRate,
                    Name    = property.FullName
                });

                dataService.Insert(new Rate {
                    Code    = property.Code,
                    TaxRate = (double)property.TaxRate,
                    Name    = property.Name
                });
            }
        }
Exemple #5
0
        private void LoadRates()
        {
            Rates.Clear();
            dataService.DeleteAll(new Rate());
            var type           = typeof(Rates);
            var properties     = type.GetRuntimeFields();
            var nameType       = typeof(NameRates);
            var nameProperties = nameType.GetRuntimeFields();

            foreach (var property in properties)
            {
                var code = property.Name.Substring(1, 3);
                foreach (var nameProperty in nameProperties)
                {
                    var nameCode = nameProperty.Name.Substring(1, 3);
                    if (code == nameCode)
                    {
                        Rates.Add(new Rate
                        {
                            Code    = code,
                            TaxRate = (double)property.GetValue(exchangeRates.Rates),
                            Name    = code + " - " + (string)nameProperty.GetValue(nameRates),
                        });
                        dataService.Insert(new Rate
                        {
                            Code    = code,
                            TaxRate = (double)property.GetValue(exchangeRates.Rates),
                            Name    = code + " - " + (string)nameProperty.GetValue(nameRates),
                        });
                    }
                }
            }
        }
Exemple #6
0
        private void LoadRatesOnLine()
        {
            Rates.Clear();
            var type                  = typeof(Rates);
            var properties            = type.GetRuntimeFields();
            var typeDescription       = typeof(RatesDescrption);
            var propertiesDescription = typeDescription.GetRuntimeFields();

            foreach (var property in properties)
            {
                var code = property.Name.Substring(1, 3);
                foreach (var description in propertiesDescription)
                {
                    var codeDescription = description.Name.Substring(1, 3);
                    if (code.Equals(codeDescription))
                    {
                        var newRate = new Rate();
                        newRate.Code    = code;
                        newRate.TaxRate = (double)property.GetValue(exchangeRates.Rates);
                        newRate.Name    = code + " - " + (string)description.GetValue(ratesDescription);
                        //Almacenar en BD
                        dataService.DeleteAndInsert <Rate>(newRate);
                        // Se carga a la ObservableCollection
                        Rates.Add(newRate);
                        //Consultar Preferencias
                        ConsultarPreferencias(newRate);
                        break;
                    }
                }
            }
        }
Exemple #7
0
        protected override void EstablishContext()
        {
            base.EstablishContext();
            Rates.Add(CreateRate());

            ScenarioExceptionsExpected = true;
        }
Exemple #8
0
        protected override void EstablishContext()
        {
            base.EstablishContext();
            Rates.Add(CreateRate(buyRate: "not-valid-double"));

            ScenarioExceptionsExpected = true;
        }
Exemple #9
0
 public void AddRates(MovieRating mr)
 {
     if (Rates == null)
     {
         Rates = new List <MovieRating>();
     }
     Rates.Add(mr);
 }
Exemple #10
0
        protected override void EstablishContext()
        {
            base.EstablishContext();
            Rates.Add(CreateRate(currencyCode: "FakeCode1"));
            Rates.Add(CreateRate(currencyCode: "FakeCode2", buyRate: "invalid-rate"));

            ScenarioExceptionsExpected = true;
        }
Exemple #11
0
        //1-5
        public void RateTraining(int rate)
        {
            if (rate < 1 || rate > 5)
            {
                throw new Exception("Invalid rating. Rating should be between 1 and 5");
            }

            Rates.Add(rate);
        }
Exemple #12
0
        public void Build(string input)
        {
            foreach (var t in input)
            {
                if (!Rates.ContainsKey(t))
                {
                    Rates.Add(t, 0);
                }

                Rates[t]++;
            }

            AfterBuildPrep();
        }
Exemple #13
0
        private void LoadRatesOffLine()
        {
            Rates.Clear();
            List <Rate> rateList = new List <Rate>();

            rateList = dataService.Get <Rate>(false);

            for (int i = 0; i < rateList.Count; i++)
            {
                Rates.Add(rateList[i]);
                //Consultar Preferencias
                ConsultarPreferencias(rateList[i]);
            }
        }
        private void ComputeRateParameters(int picClockSpeed)
        {
            int rate;

            if (Int32.TryParse(DesiredBaudRateText, out rate))
            {
                Rates.Clear();
                Rates.Add(BaudRateCalculator.Compute(SerialDeviceType.PIC32, rate, picClockSpeed));
                Rates.Add(BaudRateCalculator.Compute(SerialDeviceType.FtdiLow, rate));
                Rates.Add(BaudRateCalculator.Compute(SerialDeviceType.FtdiHigh, rate));
                ActualBaudRateText = String.Format("{0:F1}", Rates[0].ActualBaud);
                ErrorRateText      = String.Format("{0:F1}", Rates[0].PercentError);
            }
        }
Exemple #15
0
        private void GetDataFromBD()
        {
            Rates.Clear();
            List <Rate> rates = dataService.Get <Rate>(false);

            foreach (var rate in rates)
            {
                Rates.Add(new Rate
                {
                    Code    = rate.Code,
                    Name    = rate.Name,
                    TaxRate = (double)rate.TaxRate
                });
            }
        }
Exemple #16
0
        private void ConvertRates()
        {
            Rates.Clear();
            var type       = typeof(Rates);
            var properties = type.GetRuntimeFields();

            foreach (var property in properties)
            {
                var code = property.Name.Substring(1, 3);
                Rates.Add(new Rate
                {
                    Code    = code,
                    TaxRate = (double)property.GetValue(exchangeRates.Rates),
                });
            }
        }
Exemple #17
0
        private async Task UpdateRatesAsync(HistoricalRates historicalRates)
        {
            foreach (var rate in historicalRates.Rates)
            {
                if (!Rates.ContainsKey(rate.Key))
                {
                    Rates.Add(rate.Key, rate.Value);
                }
                else if (Rates[rate.Key] != rate.Value)
                {
                    Rates[rate.Key] = rate.Value;
                }
            }

            await _filesManagerService.SaveRatesAsync(_settingsService.BaseCurrency, Rates);
        }
        private void ReloadRates(List <Rate> rates)
        {
            //  Inicializa el objeto Rate()   \\
            Rates.Clear();

            //  Carga el objeto Rates() \\
            foreach (var rate in rates.OrderBy(r => r.Name))
            {
                Rates.Add(new Rate
                {
                    Code    = rate.Code,
                    Name    = rate.Name,
                    RateId  = rate.RateId,
                    TaxRate = rate.TaxRate,
                });
            }
        }
Exemple #19
0
        public async Task Thank(SocketUser user)
        {
            if (user == this.Context.User)
            {
                await this.ReplyAsync("You cannot thank yourself.");
            }
            else if (_thanks.CanThank(user))
            {
                await Rates.Add(user, 1);

                await this.ReplyAsync($"{this.Context.User.Mention} thanked {user.Mention}!");
            }
            else
            {
                await this.ReplyAsync($"You must wait {new TimeSpan(0, 0, (int)Math.Ceiling(_thanks.WaitTime(user))).ToString(@"mm\:ss")} to thank again.");
            }
        }
Exemple #20
0
 // SobreCarga del metodo Rate(String num)
 // Metodo que dado dos numers enters (entre 0 y 5), permite agregar una valorizacion al Chatbot
 // Entrada : String con la valorizacion
 // Salida : String con verificación.
 public String Rate(String num, String num2)
 {
     try
     {
         if (LogCountBegin() == LogCountEnd() && LogCountBegin() != 0 && LogCountEnd() != 0)
         {
             int actualNum;
             int actualNum2;
             try
             {
                 actualNum  = Int32.Parse(num);
                 actualNum2 = Int32.Parse(num2);
                 try
                 {
                     if (actualNum >= 0 && actualNum <= 5)
                     {
                         chatbot.Rates.Add((actualNum + actualNum2) / 2);
                         Rates.Add((actualNum + actualNum2) / 2);
                         return("AVISO : El rate se ha añadido satisfactoriamente.");
                     }
                     return("AVISO : Rate fuera del rango establecido.");
                 }
                 catch (ArgumentNullException e)
                 {
                     Console.WriteLine(e);
                     return("AVISO : Debe iniciar una conversacion");
                 }
             }
             catch (FormatException e)
             {
                 Console.WriteLine(e);
                 return("AVISO : Porfavor, ingrese un número valido.");
             }
         }
         else
         {
             return("AVISO : Porfavor debe iniciar y cerrar una conversacion");
         }
     }
     catch (IndexOutOfRangeException e)
     {
         Console.WriteLine(e);
         return("AVISO : Debe volver a iniciar y cerrar una conversacion");
     }
 }
Exemple #21
0
        private bool LoadExtenalData()
        {
            IsLoading = true;
            using (var client = new WebClient())
            {
                var xml = client.DownloadString(new Uri(ExternalFeed));

                XmlSerializer serializer = new XmlSerializer(typeof(ExchangeRates));
                var           xmlReader  = new StringReader(xml);

                var rateCollectionModel = (ExchangeRates)serializer.Deserialize(xmlReader);
                foreach (var cur in rateCollectionModel.DailyRates.Currencies)
                {
                    var rate = double.Parse(cur.Rate);
                    Rates.Add(cur.Code, new RateModel {
                        Rate = rate, Code = cur.Code, Desc = cur.Desc
                    });
                }
            }
            IsLoading = false;
            return(true);
        }
Exemple #22
0
        public async Task <List <RateRecord> > GetRates(bool fromMemory = false)
        {
            List <RateRecord> records = new List <RateRecord>();

            if (_proxy.IsConnected && !fromMemory || _proxy.IsConnected && !Rates.Any())
            {
                //Try catch in case that proxy disconnect before next keepAlive check to return stored data
                try
                {
                    var rates = await _proxy.GetRates();

                    if (rates != null)
                    {
                        Rates.Clear();
                    }
                    foreach (var rate in rates)
                    {
                        records.Add(rate);
                        Rates.Add(rate);
                    }
                }
                catch (Exception ex)
                {
                    foreach (var rate in Rates)
                    {
                        records.Add(rate);
                    }
                }
            }
            else
            {
                foreach (var rate in Rates)
                {
                    records.Add(rate);
                }
            }
            return(Rates);
        }
Exemple #23
0
        public static List <Room> GetRoomsForDB(int hotelID)
        {
            string sql = @"select roomName,BedArea,Area,Floor,NetType,r.BedType,r.RoomTypeId,r.IsChildRoom,Remark,p.RoomID,e.RatePlanID,
                           p.RatePlanName,p.ishourRoom,p.BedType as RatePlanBedType,
                           p.NetInfo,p.zaocan,p.Discount,e.price,e.dates,e.Available,p.PayType
                           from HotelRoom r with(nolock)
                           inner join HotelRatePlan p with(nolock)
                           on r.id=p.RoomID 
                           inner join HotelRate e with(nolock)
                           on e.RatePlanID=p.id
                           where r.hotelID=@hotelID and r.Enabled=1 and p.Enabled=1 
                           order by r.id,p.id,dates";
            var    dt  = HotelCloud.SqlServer.SQLHelper.Get_DataTable(sql, HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                { "hotelID", new HotelCloud.SqlServer.DBParam {
                      ParamValue = hotelID.ToString()
                  } }
            });
            List <Room>     rooms       = new List <Room>();
            Room            room        = new Room();
            List <RatePlan> RatePlans   = new List <RatePlan>();
            RatePlan        rateplan    = new RatePlan();
            List <Rate>     Rates       = new List <Rate>();
            string          croomID     = "";
            string          cRatePlanID = "";

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                if (!cRatePlanID.Equals(dr["RatePlanID"].ToString()))
                {
                    if (!cRatePlanID.Equals(""))
                    {
                        rateplan.Rates = Rates;
                        RatePlans.Add(rateplan);
                    }
                    cRatePlanID           = dr["RatePlanID"].ToString();
                    rateplan              = new RatePlan();
                    rateplan.BedType      = dr["rateplanbedtype"].ToString();
                    rateplan.NetInfo      = dr["netinfo"].ToString();
                    rateplan.ID           = WeiXinPublic.ConvertHelper.ToInt(dr["rateplanid"]);
                    rateplan.RatePlanName = dr["rateplanname"].ToString();
                    rateplan.ZaoCan       = dr["zaocan"].ToString();
                    rateplan.IsHourRoom   = WeiXinPublic.ConvertHelper.ToInt(dr["isHourRoom"]);
                    rateplan.Discount     = WeiXinPublic.ConvertHelper.ToDouble(dr["Discount"]);
                    rateplan.PayType      = Convert.ToString(dr["paytype"]);
                    Rates = new List <Rate>();
                }
                if ((!croomID.Equals(dr["RoomID"].ToString())))
                {
                    if (!croomID.Equals(""))
                    {
                        room.RatePlans = RatePlans;
                        rooms.Add(room);
                    }
                    croomID          = dr["RoomID"].ToString();
                    room             = new Room();
                    room.Area        = dr["area"].ToString();
                    room.BedArea     = dr["bedarea"].ToString();
                    room.BedType     = dr["bedtype"].ToString();
                    room.Floor       = dr["floor"].ToString();
                    room.ID          = Convert.ToInt32(dr["roomID"].ToString());
                    room.NetType     = dr["nettype"].ToString();
                    room.Remark      = dr["Remark"].ToString();
                    room.RoomName    = dr["RoomName"].ToString();
                    room.IsChildRoom = WeiXinPublic.ConvertHelper.ToInt(dr["IsChildRoom"]);
                    room.RoomTypeId  = WeiXinPublic.ConvertHelper.ToInt(dr["RoomTypeId"]);
                    RatePlans        = new List <RatePlan>();
                }

                Rate r = new Rate();
                r.Available = Convert.ToInt32(dr["Available"].ToString());
                r.Dates     = Convert.ToDateTime(dr["dates"].ToString());
                r.Price     = Convert.ToInt32(dr["Price"].ToString());
                Rates.Add(r);
            }
            if (dt.Rows.Count > 0)
            {
                rateplan.Rates = Rates;
                RatePlans.Add(rateplan);
                room.RatePlans = RatePlans;
                rooms.Add(room);
            }
            return(rooms);
        }
Exemple #24
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     Rates.Add(CreateRate(currencyCode: "FakeCode1"));
     Rates.Add(CreateRate(currencyCode: "FakeCode2"));
 }
Exemple #25
0
        public void Blinds()
        {
            if (PlayUsers.Count == 2)
            {
                if (PlayUsers[0] == Dealer)
                {
                    Dealer.CoinsTable -= 50;
                    Rates.Add(new Rate {
                        EmailUser = Dealer.Email, Coins = 50
                    });
                    Dealer.Stake             = 50;
                    PlayUsers[1].CoinsTable -= 100;
                    Rates.Add(new Rate {
                        EmailUser = PlayUsers[1].Email, Coins = 100
                    });
                    PlayUsers[1].Stake = 100;
                }
                else
                {
                    Dealer.CoinsTable -= 50;
                    Rates.Add(new Rate {
                        EmailUser = Dealer.Email, Coins = 50
                    });
                    Dealer.Stake             = 50;
                    PlayUsers[0].CoinsTable -= 100;
                    Rates.Add(new Rate {
                        EmailUser = PlayUsers[0].Email, Coins = 100
                    });
                    PlayUsers[0].Stake = 100;
                }
            }
            else
            {
                int  indexDealer = PlayUsers.IndexOf(Dealer);
                User user1;
                User user2;
                if (indexDealer + 1 == PlayUsers.Count)
                {
                    user1 = PlayUsers[0];
                    user2 = PlayUsers[1];
                }
                else if (indexDealer + 1 == PlayUsers.Count - 1)
                {
                    user1 = PlayUsers.Last();
                    user2 = PlayUsers.First();
                }
                else
                {
                    user1 = PlayUsers[indexDealer + 1];
                    user2 = PlayUsers[indexDealer + 2];
                }

                user1.CoinsTable -= 50;
                Rates.Add(new Rate {
                    EmailUser = user1.Email, Coins = 50
                });
                user2.CoinsTable -= 100;
                Rates.Add(new Rate {
                    EmailUser = user2.Email, Coins = 100
                });
            }
            foreach (var stake in Rates)
            {
                Bank.AddCoins(stake.Coins);
            }
        }
Exemple #26
0
        public async Task Spawn(int amount)
        {
            await Rates.Add(this.Context.User, amount);

            await this.ReplyAsync($"Spawning in {amount} rates from thin air...");
        }
Exemple #27
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     Rates.Add(CreateRate());
 }