Example #1
0
        public static void SetCreatedCountryPercents()
        {
            // Set countries' percentages to the average of it's parts percentages
            DOSMapsDataContext dataContext = new DOSMapsDataContext();
            List <Country>     countries   = (from country in dataContext.Countries
                                              where country.PrayerNeed == 0.0
                                              join chunk in dataContext.Chunks on country.Chunk_ID equals chunk.ID
                                              join part in dataContext.Parts on country.ID equals part.Country_ID
                                              select country).ToList();

            foreach (Country country in countries)
            {
                double needSum     = 0.0;
                double resourceSum = 0.0;
                foreach (Part part in country.Parts)
                {
                    needSum     += part.PrayerNeed;
                    resourceSum += part.PrayerResource;
                }
                country.PrayerNeed           = needSum / country.Parts.Count();
                country.PrayerResource       = resourceSum / country.Parts.Count();
                country.Chunk.PrayerNeed     = country.PrayerNeed;
                country.Chunk.PrayerResource = country.PrayerResource;
            }
            dataContext.SubmitChanges();
        }
Example #2
0
        public static void SavePrayersFor(List <PrayersFor> prayersFor)
        {
            DOSMapsDataContext dataContext = new DOSMapsDataContext();

            dataContext.PrayersFors.InsertAllOnSubmit(prayersFor);
            dataContext.SubmitChanges();
        }
Example #3
0
        public static void SaveConversions(List <Conversion> conversions)
        {
            DOSMapsDataContext dataContext = new DOSMapsDataContext();

            dataContext.Conversions.InsertAllOnSubmit(conversions);
            dataContext.SubmitChanges();
        }
Example #4
0
        public static void SaveData(List <Part> parts, List <Country> countries, List <Chunk> chunks)
        {
            DOSMapsDataContext dataContext = new DOSMapsDataContext();

            dataContext.Parts.InsertAllOnSubmit(parts);
            dataContext.Countries.InsertAllOnSubmit(countries);
            dataContext.Chunks.InsertAllOnSubmit(chunks);
            dataContext.SubmitChanges();
        }
Example #5
0
        public static void SaveCountryName(Guid ID, String countryName, String countryCode)
        {
            DOSMapsDataContext dataContext = new DOSMapsDataContext();
            Country            modified    = (from country in dataContext.Countries
                                              where country.ID == ID
                                              select country).SingleOrDefault();

            modified.Name = countryName;
            modified.Code = countryCode;
            dataContext.SubmitChanges();
        }
Example #6
0
        public static void SaveMulti(String ID, List <Chunk> countryChunks, List <Country> countries)
        {
            DOSMapsDataContext dataContext = new DOSMapsDataContext();

            dataContext.Countries.InsertAllOnSubmit(countries);
            dataContext.Chunks.InsertAllOnSubmit(countryChunks);
            Chunk modified = (from chunk in dataContext.Chunks
                              where chunk.ID == ID
                              select chunk).SingleOrDefault();

            modified.MultiComplete = true;
            dataContext.SubmitChanges();
        }