public async Task <AgeRange> AddAgeRangeAsync(AgeRange ageRange)
        {
            _context.AgeRanges.Add(ageRange);
            await _context.SaveChangesAsync();

            return(ageRange);
        }
        public void Overlap_E1IsS2()
        {
            AgeRange range1 = new AgeRange(10, 20);
            AgeRange range2 = new AgeRange(20, 50);

            Assert.IsTrue(range1.Overlaps(range2));
        }
Esempio n. 3
0
        private void cb_Branch_SelectedIndexChanged(object sender, EventArgs e)
        {
            lst_Modules.Items.Clear();
            List <DomainModel.BusinessObject.GameCoding> gameCodingList = new List <GameCoding>();
            STEM stemDomain = new STEM();

            stemDomain.Id = cb_Track.SelectedValue.ToString()[0].ToString();
            AgeRange        ageRange = GetAgeRange(cb_ageGroup.SelectedItem.ToString());
            List <Branches> branches = gameCodingManager.LoadBranchesPerStem(stemDomain.Id);
            Branches        branch   = new Branches();

            foreach (Branches branchItem in branches)
            {
                if (branchItem.branchName == cb_Branch.SelectedItem.ToString())
                {
                    branch = branchItem;
                }
            }
            List <Student> students           = GetStudentsIngroup(tb_GroupMan.Text);
            List <int>     excludedModulesIds = GetTakenModulesIdAllStudent(students);

            gameCodingList = gameCodingManager.LoadGameModuleByAgeAndSTEMAndBranch(ageRange, stemDomain, branch);
            List <SelectValue> gameNamesList = GetGameName(gameCodingList, excludedModulesIds);

            foreach (SelectValue name in gameNamesList)
            {
                lst_Modules.Items.Add(name.Text);
            }
        }
Esempio n. 4
0
        public override void Seed()
        {
            var lowerBound = 1;
            var upperBound = 5;
            var minAge     = 1;

            for (int i = 0; i < this.SeedDataCount; i++)
            {
                var ageRange = new AgeRange()
                {
                    MinAge = minAge,
                    MaxAge = upperBound
                };

                this.ToyStoreContext.AgeRanges.Add(ageRange);

                if (i % 100 == 0)
                {
                    this.Logger.Log(".");
                    this.ToyStoreContext.SaveChanges();
                }

                this.ChangeAgeValue(ref minAge, ref lowerBound, ref upperBound);
            }

            this.ToyStoreContext.SaveChanges();
            this.Logger.Log(Environment.NewLine);
        }
Esempio n. 5
0
        private void AddStudentToGroup(Student student)
        {
            bool     added    = false;
            int      age      = GetAge(student.BirthDate);
            AgeRange ageRange = GetStudentAgeRange(age);

            if (runningGroups.Count == 0)
            {
                CreateGroup(ageRange, student);
            }
            else
            {
                foreach (Group runGroup in runningGroups)
                {
                    if (runGroup.ageRange.ID == ageRange.ID)
                    {
                        if (!runGroup.students.Contains(student))
                        {
                            runGroup.students.Add(student);
                        }
                        added = true;
                    }
                }
                if (added == false)
                {
                    CreateGroup(ageRange, student);
                }
            }
        }
Esempio n. 6
0
        public AgeRange Update(AgeRange ageRange)
        {
            _context.Update(ageRange);
            _context.SaveChanges();

            return(ageRange);
        }
Esempio n. 7
0
        public AgeRange Create(AgeRange ageRange)
        {
            _context.AgeRanges.Add(ageRange);
            _context.SaveChanges();

            return(ageRange);
        }
Esempio n. 8
0
        public IHttpActionResult PutAgeRange(int id, AgeRange ageRange)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ageRange.AgeRangeID)
            {
                return(BadRequest());
            }

            db.Entry(ageRange).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AgeRangeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 9
0
        //---------------------------------------------------------------------

        /// <summary>
        /// constructor, assign members of the stucture
        /// </summary>
        public InclusionRule(string inclusion_type,
                             AgeRange age_range,
                             string temp_percent,
                             List <string> species_list)
        {
            //assign members of the struct
            this.inclusion_type = inclusion_type;
            this.age_range      = age_range;
            //check for type 'percentage' by looking for the % character
            string [] split = temp_percent.Split(new char [] { '%' });
            //try to make a percentage.  if this doesn't work then check for keyword 'highest'
            try {
                percentOfCells = ((double)Convert.ToInt32(split[0])) / 100;
            }
            catch (Exception) {
                //and set percentOfCells to -1 (the flag for InclusionRequirement to handle)
                percentOfCells = -1;
            }
            this.species_list = species_list;
            //get the species index list using species name
            this.species_index_list = new List <int>();
            foreach (string species in species_list)
            {
                if (Model.Core.Species[species] != null)
                {
                    this.species_index_list.Add(Model.Core.Species[species].Index);
                }
            }
            //Model.Core.UI.WriteLine("species index = {0}", this.species_index);
        }
Esempio n. 10
0
        private Range GetAge(AgeRange range)
        {
            switch (range)
            {
            case AgeRange.ZERO_TO_SEVENTEEN:
                return(new Range {
                    From = 0, To = 17
                });

            case AgeRange.EIGHTEEN_TO_SIXTY_FOUR:
                return(new Range {
                    From = 18, To = 64
                });

            case AgeRange.SIXTY_FIVE_PLUS:
                return(new Range {
                    From = 65, To = int.MaxValue
                });

            default:
                return(new Range {
                    From = 0, To = 0
                });
            }
        }
        public void Overlap_R1AfterR2()
        {
            AgeRange range1 = new AgeRange(100, 200);
            AgeRange range2 = new AgeRange(15, 50);

            Assert.IsFalse(range1.Overlaps(range2));
        }
        public void Overlap_R1IncludesR2()
        {
            AgeRange range1 = new AgeRange(10, 200);
            AgeRange range2 = new AgeRange(15, 50);

            Assert.IsTrue(range1.Overlaps(range2));
        }
 public void SetAgeRange(AgeRange ageRange)
 {
     if (ageRange != null)
     {
         this.ageRange = ageRange.Value;
     }
 }
        public void Overlap_R1BeforeR2()
        {
            AgeRange range1 = new AgeRange(10, 20);
            AgeRange range2 = new AgeRange(21, 50);

            Assert.IsFalse(range1.Overlaps(range2));
        }
        //---------------------------------------------------------------------

        /// <summary>
        /// Reads a cohort age or a range of ages (format: age-age) followed
        /// by an optional percentage for partial thinning.
        /// </summary>
        /// <remarks>
        /// The optional percentage is bracketed by parenthesis.
        /// </remarks>
        public static InputValue <AgeRange> ReadAgeOrRange(StringReader reader,
                                                           out int index)
        {
            TextReader.SkipWhitespace(reader);
            index = reader.Index;

            string word = ReadWord(reader, '(');

            if (word == "")
            {
                throw new InputValueException();  // Missing value
            }
            AgeRange ageRange = AgeRangeParsing.ParseAgeOrRange(word);

            //  Does a percentage follow?
            TextReader.SkipWhitespace(reader);
            if (reader.Peek() == '(')
            {
                int ignore;
                InputValue <Percentage> percentage = ReadPercentage(reader, out ignore);
                percentages[ageRange.Start] = percentage;
            }

            return(new InputValue <AgeRange>(ageRange, word));
        }
        //---------------------------------------------------------------------

        /// <summary>
        /// Reads a cohort age or a range of ages (format: age-age) followed
        /// by an optional percentage for partial thinning.
        /// </summary>
        /// <remarks>
        /// The optional percentage is bracketed by parenthesis.
        /// </remarks>
        public static InputValue <AgeRange> ReadAgeOrRange(StringReader reader,
                                                           out int index)
        {
            TextReader.SkipWhitespace(reader);
            index = reader.Index;

            string word = ReadWord(reader, '(');

            if (word == "")
            {
                throw new InputValueException();  // Missing value
            }
            AgeRange ageRange = AgeRangeParsing.ParseAgeOrRange(word);

            //  Does a percentage follow?
            TextReader.SkipWhitespace(reader);
            if (reader.Peek() == '(')
            {
                InputValue <uint> removal = ReadTreeRemoval(reader);

                if (removal.String != "(100%)")
                {
                    treeremovals[ageRange.Start] = removal;
                }
            }

            return(new InputValue <AgeRange>(ageRange, word));
        }
        public void Overlap_S1IsE2()
        {
            AgeRange range1 = new AgeRange(10, 20);
            AgeRange range2 = new AgeRange(3, 10);

            Assert.IsTrue(range1.Overlaps(range2));
        }
Esempio n. 18
0
 public void RandInfo(TDBaseNameData nameData, AgeRange range = AgeRange.Adult, Gender gender = Gender.Male, string lastName = null)
 {
     IsCelebrity = false;
     AgeRange    = range;
     Gender      = gender;
     NameLib     = nameData.TDID;
     Age         = RandUtil.RangeInt(AgeRangeData[AgeRange]);
     NameData    = GetNameData(NameLib);
     HeadIcon    = NameData.RandHeadIcon(Gender, Const.PTag_Normal);
     if (lastName.IsInv())
     {
         LastName = NameData.RandLastNameKey();
     }
     else
     {
         if (BaseLanguageMgr.AllLastNames.Contains(lastName))
         {
             LastName = lastName;
         }
         else
         {
             throw new Exception("没有这个姓氏:" + lastName);
         }
     }
     if (FirstName.IsInv())
     {
         FirstName = NameData.RandFirstNameKey(Gender);
     }
     OnRandInfo();
 }
    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="adGroupId">Id of the ad group to which criteria are
    /// added.</param>
    public void Run(AdWordsUser user, long adGroupId) {
      // Get the AdGroupCriterionService.
      AdGroupCriterionService adGroupCriterionService =
          (AdGroupCriterionService) user.GetService(AdWordsService.v201509.AdGroupCriterionService);

      // Create biddable ad group criterion for gender
      Gender genderTarget = new Gender();
      // Criterion Id for male. The IDs can be found here
      // https://developers.google.com/adwords/api/docs/appendix/genders
      genderTarget.id = 10;

      BiddableAdGroupCriterion genderBiddableAdGroupCriterion = new BiddableAdGroupCriterion();
      genderBiddableAdGroupCriterion.adGroupId = adGroupId;
      genderBiddableAdGroupCriterion.criterion = genderTarget;

      // Create negative ad group criterion for age range
      AgeRange ageRangeNegative = new AgeRange();
      // Criterion Id for age 18 to 24. The IDs can be found here
      // https://developers.google.com/adwords/api/docs/appendix/ages

      ageRangeNegative.id = 503001;
      NegativeAdGroupCriterion ageRangeNegativeAdGroupCriterion = new NegativeAdGroupCriterion();
      ageRangeNegativeAdGroupCriterion.adGroupId = adGroupId;
      ageRangeNegativeAdGroupCriterion.criterion = ageRangeNegative;

      // Create operations.
      AdGroupCriterionOperation genderBiddableAdGroupCriterionOperation =
          new AdGroupCriterionOperation();
      genderBiddableAdGroupCriterionOperation.operand = genderBiddableAdGroupCriterion;
      genderBiddableAdGroupCriterionOperation.@operator = Operator.ADD;

      AdGroupCriterionOperation ageRangeNegativeAdGroupCriterionOperation =
          new AdGroupCriterionOperation();
      ageRangeNegativeAdGroupCriterionOperation.operand = ageRangeNegativeAdGroupCriterion;
      ageRangeNegativeAdGroupCriterionOperation.@operator = Operator.ADD;

      AdGroupCriterionOperation[] operations = new AdGroupCriterionOperation[] {
          genderBiddableAdGroupCriterionOperation, ageRangeNegativeAdGroupCriterionOperation};

      try {
        // Add ad group criteria.
        AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);

        // Display ad group criteria.
        if (result != null && result.value != null) {
          foreach (AdGroupCriterion adGroupCriterionResult in result.value) {
            Console.WriteLine("Ad group criterion with ad group id \"{0}\", criterion id " +
                "\"{1}\", and type \"{2}\" was added.", adGroupCriterionResult.adGroupId,
                adGroupCriterionResult.criterion.id,
                adGroupCriterionResult.criterion.CriterionType);
          }
        } else {
          Console.WriteLine("No ad group criteria were added.");
        }
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to create ad group criteria.", e);
      }
    }
Esempio n. 20
0
        public void JavascriptInjectionTest()
        {
            // arrange
            IAgeRange <PersonModel> AgeRangeTest = new AgeRange();
            string HtmlEncodedString             = "&lt;script&gt;alert(&quot;Boo!&quot;)&lt;/script&gt;";

            // assert
            Assert.IsFalse(AgeRangeTest.CheckHtmlEncodedInput(HtmlEncodedString), "Potential Dangerous Code has been Supplied");
        }
Esempio n. 21
0
        public void DatabaseIDPositiveRange()
        {
            // arrange
            IAgeRange <PersonModel> AgeRangeTest = new AgeRange();
            long NegativeAge = -32;

            // assert
            Assert.IsFalse(AgeRangeTest.CheckInputPositiveIDRange(NegativeAge), "database Record ID cannot be a negative number");
        }
Esempio n. 22
0
        public Advertisement(string text, AgeRange ageRange, Interests interests)

        {
            this.text = text;

            this.ageRange = ageRange;

            this.interests = interests;
        }
Esempio n. 23
0
        public void NullorEmptyInputValidation()
        {
            // arrange
            IAgeRange <PersonModel> AgeRangeTest = new AgeRange();
            string NullorEmptyTestString         = string.Empty;

            // assert
            Assert.IsFalse(AgeRangeTest.CheckInputForNullorEmpty(NullorEmptyTestString), "An input supplied has no value");
        }
Esempio n. 24
0
 /// <summary> Creates new person.</summary>
 /// <param name="displayName">Name of the person that is displayed to the user. Does not have to be unique or persistent.</param>
 /// <param name="uniqueIdentifier">Unique persistent identifier of the person. </param>
 public Person(string inUniqueIdentifier, string inDisplayName = null, GenderEnum gender = GenderEnum.NEUTER,
               AgeRange age = null, string inProfileImageUrl = null)
 {
     this.m_Name             = inDisplayName;
     this.m_UniqueIdentifier = inUniqueIdentifier;
     this.m_Gender           = gender;
     this.m_Age             = age;
     this.m_ProfileImageUrl = inProfileImageUrl;
 }
Esempio n. 25
0
        public void AgeConvertionValidation()
        {
            // arrange
            IAgeRange <PersonModel> AgeRangeTest = new AgeRange();
            int NegativeAge = -32;

            // assert
            Assert.IsFalse(AgeRangeTest.CheckInputPositiveAge(NegativeAge), "Age Input cannot be a negative number");
        }
Esempio n. 26
0
        public string AddAgeRange(string ageRangeDescription, int admin)
        {
            using (var context = new FSOSSContext())
            {
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }
                    if (ageRangeDescription == "" || ageRangeDescription == null)
                    {
                        throw new Exception("Please enter an Age Range Description");
                    }
                    //add check for pre-use
                    var ageList = from x in context.AgeRanges
                                  where x.age_range_description.ToLower().Equals(ageRangeDescription.ToLower()) && !x.archived_yn
                                  select new AgeRangePOCO()
                    {
                        ageRangeDescription = x.age_range_description
                    };


                    var GoneageList = from x in context.AgeRanges
                                      where x.age_range_description.ToLower().Equals(ageRangeDescription.ToLower()) && x.archived_yn
                                      select new AgeRangePOCO()
                    {
                        ageRangeDescription = x.age_range_description
                    };
                    if (ageList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The age range \"" + ageRangeDescription.ToLower() + "\" already exists. Please enter a new age range.");
                    }
                    else if (GoneageList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The age range \"" + ageRangeDescription.ToLower() + "\" already exists and is Archived. Please enter a new age range.");
                    }

                    else
                    {
                        AgeRange age = new AgeRange();
                        age.age_range_description    = ageRangeDescription;
                        age.administrator_account_id = admin;
                        age.date_modified            = DateTime.Now;
                        age.archived_yn = false;
                        context.AgeRanges.Add(age);
                        context.SaveChanges();
                        return("Age Range " + ageRangeDescription + " added.");
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
Esempio n. 27
0
 public void Insert1_Warmup()
 {
     using (ProductDataSession session = new ProductDataSession("sales"))
     {
         AgeRange ageRange = new AgeRange {
             Max = 20, Min = 0
         };
         session.Insert(ageRange);
     }
 }
 public double CalculateYearlyPrice(AgeRange AgeRange, TypeOfVehicle TypeOfVehicle, PolicyType PolicyType)
 {
     double price = 0;
     this.ageRange = AgeRange;
     this.typeOfVehicle = TypeOfVehicle;
     this.policyType = PolicyType;
     lengthModfier = 3;
     price = CalculatePrice();
     return price;
 }
Esempio n. 29
0
        public AgeRange MapData(AgeRangeModel arm, int vacId)
        {
            AgeRange mappedAgeRange = new AgeRange();

            mappedAgeRange.Id           = arm.Id;
            mappedAgeRange.Min_leeftijd = arm.Min_leeftijd;
            mappedAgeRange.Max_leeftijd = arm.Max_leeftijd;
            mappedAgeRange.Vacation     = _db.Vacations.Find(vacId);
            return(mappedAgeRange);
        }
        private void CopyAgeRange(AgeRange source, DtoAgeRange target)
        {
            target.Id = source.Id;

            if (EditMode)
            {
                target.Min = source.Min;
                target.Max = source.Max;
            }
        }
 public void SetAgeRange(AgeRange ar)
 {
     _editingAgeRange = ar;
     if (AgeRange != null)
     {
         AgeRange.ErrorsChanged -= RaiseCanExecuteChanged;
     }
     AgeRange = new DtoAgeRange();
     AgeRange.ErrorsChanged += RaiseCanExecuteChanged;
     CopyAgeRange(ar, AgeRange);
 }
Esempio n. 32
0
        public IHttpActionResult GetAgeRange(int id)
        {
            AgeRange ageRange = db.AgeRanges.Find(id);

            if (ageRange == null)
            {
                return(NotFound());
            }

            return(Ok(ageRange));
        }
 /// <summary>
 /// controller method calls database modifcation methods as well as controls the system message
 /// </summary>
 public string ModifyPolicy(int id, string Name, TypeOfVehicle TypeOfVehicle, PolicyType PolicyType, AgeRange AgeRange)
 {
     string returnMessage = "";
     DataBaseController controller = new DataBaseController();
     policy.Name = Name;
     policy.TypeOfVechile = TypeOfVehicle;
     policy.PolicyType = PolicyType;
     policy.AgeRange = AgeRange;
     returnMessage = controller.ModifyPolicy(policy, id);
     return returnMessage;
 }
 /// <summary>
 /// controller method calls database write new policy methods as well as controls the system messages
 /// </summary>
 public string CreateNewPolicy(string Name, TypeOfVehicle TypeOfVehicle, PolicyType PolicyType, AgeRange AgeRange)
 {
     string returnMessage = "";
     DataBaseController controller = new DataBaseController();
     policy.Name = Name;
     policy.TypeOfVechile = TypeOfVehicle;
     policy.PolicyType = PolicyType;
     policy.AgeRange = AgeRange;
     policy.CalculatePrice();
     returnMessage = controller.CreatePolicy(policy);
     return returnMessage;
 }
        //---------------------------------------------------------------------

        /// <summary>
        /// Does the range overlap another range?
        /// </summary>
        public bool Overlaps(AgeRange other)
        {
            return Contains(other.Start) || other.Contains(start);
        }