private static void LesGeobox(ExcelWorksheet sheet, int row, ExcelMatch match)
        {
            var point = sheet.GetValue(ExcelSheet.Match.GeoBox_NW_latitude, row);

            if (!string.IsNullOrEmpty(point))
            {
                match.GeoboxNWLatitude = double.Parse(point);
            }

            point = sheet.GetValue(ExcelSheet.Match.GeoBox_NW_longitude, row);

            if (!string.IsNullOrEmpty(point))
            {
                match.GeoboxNWLongitude = double.Parse(point);
            }

            point = sheet.GetValue(ExcelSheet.Match.GeoBox_SE_latitude, row);

            if (!string.IsNullOrEmpty(point))
            {
                match.GeoboxSELatitude = double.Parse(point);
            }

            point = sheet.GetValue(ExcelSheet.Match.GeoBox_SE_longitude, row);

            if (!string.IsNullOrEmpty(point))
            {
                match.GeoboxSELongitude = double.Parse(point);
            }
        }
        private void LesVåpenOppsett(ExcelWorksheet sheet, int row, ExcelMatch match)
        {
            var våpen = sheet.GetValue(ExcelSheet.Match.Pr_lag_FELLE, row);

            if (!string.IsNullOrEmpty(våpen))
            {
                match.PrLagFelle = int.Parse(våpen);
            }

            våpen = sheet.GetValue(ExcelSheet.Match.Pr_lag_BOMBE, row);

            if (!string.IsNullOrEmpty(våpen))
            {
                match.PrLagBombe = int.Parse(våpen);
            }
        }
Beispiel #3
0
        private void AddOrUpdate(ExcelMatch match)
        {
            using (var context = _dataContextFactory.Create())
            {
                var existing = (from m in context.Matcher
                                where m.MatchId == match.MatchId
                                select m).FirstOrDefault();

                if (existing == null)
                {
                    context.Matcher.Add(match.GetMatch());
                }
                else
                {
                    match.Update(existing);
                }

                context.SaveChanges();
            }
        }
            public static ExcelMatch FromMatch(Match match)
            {
                var excelMatch = new ExcelMatch();

                if (match == null)
                {
                    return(excelMatch);
                }

                excelMatch.MatchId           = match.MatchId;
                excelMatch.Navn              = match.Navn;
                excelMatch.StartTid          = match.StartTid;
                excelMatch.SluttTid          = match.SluttTid;
                excelMatch.GeoboxNWLatitude  = match.GeoboxNWLatitude;
                excelMatch.GeoboxNWLongitude = match.GeoboxNWLongitude;
                excelMatch.GeoboxSELatitude  = match.GeoboxSELatitude;
                excelMatch.GeoboxSELongitude = match.GeoboxSELongitude;

                return(excelMatch);
            }
        private void AddOrUpdate(ExcelMatch match)
        {
            using (var context = _dataContextFactory.Create())
            {
                var existing = (from m in context.Matcher
                                where m.MatchId == match.MatchId
                                select m).FirstOrDefault();

                if (existing == null)
                {
                    context.Matcher.Add(match.GetMatch());
                }
                else
                {
                    match.Update(existing);
                }

                context.SaveChanges();
            }
        }
Beispiel #6
0
        public ExcelMatch Les(ExcelWorksheet sheet)
        {
            var row = 2;
            var match = new ExcelMatch
            {
                MatchId = Guid.Parse(sheet.GetValue(ExcelSheet.Match.MatchId, row)),
                Navn = sheet.GetValue(ExcelSheet.Match.Navn, row),
                StartTid = DateTime.Parse(sheet.GetValue(ExcelSheet.Match.Starttid, row)),
                SluttTid = DateTime.Parse(sheet.GetValue(ExcelSheet.Match.Sluttid, row)),
                DefaultPoengFordeling = sheet.GetValue(ExcelSheet.Match.DefaultPostPoengfordeling, row)
            };

            LesGeobox(sheet, row, match);
            LesVåpenOppsett(sheet, row, match);

            AddOrUpdate(match);

            LeggInnVåpen();

            return match;
        }
        public ExcelMatch Les(ExcelWorksheet sheet)
        {
            var row   = 2;
            var match = new ExcelMatch
            {
                MatchId  = Guid.Parse(sheet.GetValue(ExcelSheet.Match.MatchId, row)),
                Navn     = sheet.GetValue(ExcelSheet.Match.Navn, row),
                StartTid = DateTime.Parse(sheet.GetValue(ExcelSheet.Match.Starttid, row)),
                SluttTid = DateTime.Parse(sheet.GetValue(ExcelSheet.Match.Sluttid, row)),
                DefaultPoengFordeling = sheet.GetValue(ExcelSheet.Match.DefaultPostPoengfordeling, row)
            };

            LesGeobox(sheet, row, match);
            LesVåpenOppsett(sheet, row, match);

            AddOrUpdate(match);

            LeggInnVåpen();

            return(match);
        }
Beispiel #8
0
        private static void LesGeobox(ExcelWorksheet sheet, int row, ExcelMatch match)
        {
            var point = sheet.GetValue(ExcelSheet.Match.GeoBox_NW_latitude, row);

            if (!string.IsNullOrEmpty(point))
                match.GeoboxNWLatitude = double.Parse(point);

            point = sheet.GetValue(ExcelSheet.Match.GeoBox_NW_longitude, row);

            if (!string.IsNullOrEmpty(point))
                match.GeoboxNWLongitude = double.Parse(point);

            point = sheet.GetValue(ExcelSheet.Match.GeoBox_SE_latitude, row);

            if (!string.IsNullOrEmpty(point))
                match.GeoboxSELatitude = double.Parse(point);

            point = sheet.GetValue(ExcelSheet.Match.GeoBox_SE_longitude, row);

            if (!string.IsNullOrEmpty(point))
                match.GeoboxSELongitude = double.Parse(point);
        }
Beispiel #9
0
            public static ExcelMatch FromMatch(Match match)
            {
                var excelMatch = new ExcelMatch();

                if (match == null)
                    return excelMatch;

                excelMatch.MatchId = match.MatchId;
                excelMatch.Navn = match.Navn;
                excelMatch.StartTid = match.StartTid;
                excelMatch.SluttTid = match.SluttTid;
                excelMatch.GeoboxNWLatitude = match.GeoboxNWLatitude;
                excelMatch.GeoboxNWLongitude = match.GeoboxNWLongitude;
                excelMatch.GeoboxSELatitude = match.GeoboxSELatitude;
                excelMatch.GeoboxSELongitude = match.GeoboxSELongitude;

                return excelMatch;
            }
Beispiel #10
0
        private void LesVåpenOppsett(ExcelWorksheet sheet, int row, ExcelMatch match)
        {
            var våpen = sheet.GetValue(ExcelSheet.Match.Pr_lag_FELLE, row);

            if (!string.IsNullOrEmpty(våpen))
                match.PrLagFelle = int.Parse(våpen);

            våpen = sheet.GetValue(ExcelSheet.Match.Pr_lag_BOMBE, row);

            if (!string.IsNullOrEmpty(våpen))
                match.PrLagBombe = int.Parse(våpen);
        }