public void UpdateDistinctYears()
        {
            List <Calamity> cList = DatabaseController.GetCalamities();

            dates = cList
                    .Select(c => new DateTime(c.Date.Year, c.Date.Month, 1))
                    .ToList();

            this.DistinctYears = dates
                                 .Select(c => c.Date.Year.ToString())
                                 .Distinct()
                                 .OrderBy(c => c)
                                 .ToList();

            OnPropertyChanged("DistinctYears");

            UpdateDistinctMonths();
        }
Example #2
0
        public static string GenerateRandomSerialCode()
        {
            StringBuilder rs = new StringBuilder();

            for (int i = 1; i < 15; i++)
            {
                rs.Append(charPool[rnd.Next(0, charPoolLength)]);
            }

            rs.Insert(3, "-");
            rs.Insert(8, "-");
            rs.Insert(13, "-");

            string result = rs.ToString();

            //Check incase the generated serial code happens to be not unique
            //5.567.902.560 possible combinations, but better safe than sorry
            if (!DatabaseController.CheckIfSerialCodeIsUnique(result))
            {
                result = GenerateRandomSerialCode();
            }

            return(result);
        }