Repository.Import.ExcelImport.LesInn C# (CSharp) Method

LesInn() public method

public LesInn ( byte excelBytes ) : void
excelBytes byte
return void
        public void LesInn(byte[] excelBytes)
        {
            using (var stream = new MemoryStream(excelBytes))
            {
                stream.Position = 0;
                using (ExcelPackage excelFile = new ExcelPackage(stream))
                {
                    var excel = excelFile.Workbook;

                    var excelMatch = new MatchImport.ExcelMatch();

                    Les(excel, "Match", x => excelMatch = _matchImport.Les(x));
                    Les(excel, "Poster", x => _postImport.Les(x, excelMatch));
                    Les(excel, "Lag", x => _lagImport.Les(x, excelMatch));
                    Les(excel, "Deltakere", x => _deltakerImport.Les(x, excelMatch));
                }
            }
        }

Usage Example

Example #1
0
        public void ImportExport_Clear_Import()
        {
            var match  = GetMatch();
            var lag    = LagFactory.SettOppLagMedDeltakere(3, 5, "LAG_");
            var poster = GenererPoster(10);

            Importer(match, lag, poster);

            AssertAntallIDatabasen(match.MatchId);

            var exported = _excelExport.ToByteArray(match.MatchId);

            // Clear database
            _dataContextFactory.DeleteAllData();

            // Importer
            _excelImport.LesInn(exported);

            AssertAntallIDatabasen(match.MatchId);
        }