Exemplo n.º 1
0
        public ActionResult DeleteEntry(int participantUserId, InschrijvingenModel model)
        {
            SportsEventParticipationDal participation = SportsEventParticipationDal.GetByID(participantUserId);
            if (participation!=null) {
                participation.Delete();
            }

            return RedirectToAction("Index");
        }
Exemplo n.º 2
0
        protected DataTable GetTable(String tableName, bool isForSpeaker)
        {
            InschrijvingenModel model = new InschrijvingenModel();

            DataTable table = new DataTable();
            table.TableName = tableName;

            table.Columns.Add("StartNr", typeof(int));
            table.Columns.Add("StartTijd", typeof(string));
            table.Columns.Add("Naam", typeof(string));
            table.Columns.Add("Woonplaats", typeof(string));
            table.Columns.Add("De 1e za van aug...", typeof(string));
            table.Columns.Add("Speaker", typeof(string));
            table.Columns.Add("M/V", typeof(string));
            table.Columns.Add("Food", typeof(string));
            table.Columns.Add("Camp", typeof(string));
            table.Columns.Add("Bike", typeof(string));
            table.Columns.Add("EarlyBird", typeof(string));
            table.Columns.Add("Geb. dat.", typeof(DateTime));
            table.Columns.Add("Lic. nr", typeof(string));
            table.Columns.Add("Aanmelddatum", typeof(DateTime));

            if (!isForSpeaker) {
                table.Columns.Add("UserId", typeof(int));
                table.Columns.Add("ExternalIdentifier", typeof(string));
                table.Columns.Add("MyLaps", typeof(string));
                table.Columns.Add("Email", typeof(string));
                table.Columns.Add("Telefoon", typeof(string));
                table.Columns.Add("Te betalen", typeof(int));
                table.Columns.Add("Betaald", typeof(int));
                table.Columns.Add("Voornaam", typeof(string));
                table.Columns.Add("tv", typeof(string));
                table.Columns.Add("Achternaam", typeof(string));
                table.Columns.Add("Postcode", typeof(string));
                table.Columns.Add("Straat", typeof(string));
                table.Columns.Add("Huisnr", typeof(string));
                table.Columns.Add("Toevoeging", typeof(string));
                table.Columns.Add("OpmerkingenAanOrganisatie", typeof(string));
                table.Columns.Add("DateCreated", typeof(DateTime));
                table.Columns.Add("DateUpdated", typeof(DateTime));
                table.Columns.Add("DateFirstScraped", typeof(DateTime));
                table.Columns.Add("DateLastScraped", typeof(DateTime));
            }

            // Initializeer startnummer en starttijd.
            // int startNummer = 1;
            // DateTime startTijd = HRE.Common.HreSettings.DatumTijdstipH2RE;

            foreach (var inschrijving in model.Inschrijvingen) {
                var row = isForSpeaker ?
                    new object[] {
                        inschrijving.StartNummer, // startNummer,
                        inschrijving.StartTijd.ToString(), // startTijd.ToString("H:mm:ss"),
                        Common.Common.SmartJoin(" ", new string[] { inschrijving.Voornaam, inschrijving.Tussenvoegsel, inschrijving.Achternaam}),
                        inschrijving.Woonplaats,
                        inschrijving.HebJeErZinIn,
                        inschrijving.OpmerkingenTbvSpeaker,
                        inschrijving.Geslacht,
                        inschrijving.IsEarlyBird.HasValue && inschrijving.IsEarlyBird.Value ? "1" : "0",
                        inschrijving.Food ? "1" : "0",
                        inschrijving.Camp ? "1" : "0",
                        inschrijving.Bike ? "1" : "0",
                        inschrijving.GeboorteDatum.Value.Date,
                        inschrijving.LicentieNummer,
                        inschrijving.RegistrationDate.Date
                    }
                    : new object[] {
                        inschrijving.StartNummer, // startNummer,
                        inschrijving.StartTijd.ToString(), // startTijd.ToString("H:mm:ss"),
                        Common.Common.SmartJoin(" ", new string[] { inschrijving.Voornaam, inschrijving.Tussenvoegsel, inschrijving.Achternaam}),
                        inschrijving.Woonplaats,
                        inschrijving.HebJeErZinIn,
                        inschrijving.OpmerkingenTbvSpeaker,
                        inschrijving.Geslacht,
                        inschrijving.IsEarlyBird.HasValue && inschrijving.IsEarlyBird.Value ? "1" : "0",
                        inschrijving.Food ? "1" : "0",
                        inschrijving.Camp ? "1" : "0",
                        inschrijving.Bike ? "1" : "0",
                        inschrijving.GeboorteDatum.Value.Date,
                        inschrijving.LicentieNummer,
                        inschrijving.RegistrationDate.Date,

                        // Extra velden voor NIET speakers.
                        inschrijving.UserId,
                        inschrijving.ExternalIdentifier,
                        inschrijving.MyLapsChipNummer,
                        inschrijving.Email,
                        inschrijving.Telefoon,
                        inschrijving.BedragTeBetalen,
                        inschrijving.BedragBetaald,
                        inschrijving.Voornaam,
                        inschrijving.Tussenvoegsel,
                        inschrijving.Achternaam,
                        inschrijving.Postcode,
                        inschrijving.Straat,
                        inschrijving.Huisnummer,
                        inschrijving.HuisnummerToevoeging,
                        inschrijving.OpmerkingenAanOrganisatie,
                        inschrijving.DateCreated,
                        inschrijving.DateUpdated,
                        inschrijving.DateFirstSynchronized,
                        inschrijving.DateLastSynchronized
                    };

                    table.Rows.Add(row);
                    /* if ((startNummer%HRE.Common.HreSettings.AantalPersonenPerStartschot)==0) {
                        startTijd = startTijd.AddSeconds(HRE.Common.HreSettings.AantalSecondenTussenStartschots);
                    }
                    startNummer++; */
            }

            return table;
        }
Exemplo n.º 3
0
        public ActionResult Index(InschrijvingenModel model)
        {
            if (model==null || model.SubmitAction!="Scrape") {
                if (model==null) {
                    model = new InschrijvingenModel();
                    return View(model);
                }

                if (model.SubmitAction=="Download") {
                    string filename = string.Format("HRE-{0}-{1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString().Replace(":", ""));
                    MemoryStream ms = CreateExcelFile(filename, false);

                    // Return the memorystream.
                    if (ms != null) {
                        // Rewind the memory stream to the beginning.
                        ms.Seek(0, SeekOrigin.Begin);
                        return File(ms, @"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", filename + ".xlsx");
                    } else {
                        // No Excel file, show the main 'Inschrijvingen' page.
                        return RedirectToAction("Index");
                    }
                }
            }

            Initialise(AppConstants.MeedoenOverzicht);
            try {
                int maxNumberOfItemsToScrape = model.MaxNumberOfScrapedItems;
                if (maxNumberOfItemsToScrape==0) {
                    maxNumberOfItemsToScrape = int.MaxValue;
                }

                // 0. Inloggen (sessie ID krijgen).
                // Posten naar https://mijn.triathlonbond.nl/default.asp */
                string ntbInschrijvingenStartUrl = "https://mijn.triathlonbond.nl/default.asp";

                ConsoleWrite(string.Format("Logging in via post to: {0}", ntbInschrijvingenStartUrl));

                // In form InlogFormulier invullen input met Id 'Gebruikersnaam' = SWW en input met Id 'wachtwoord' '.
                string gebruikersnaam = HreSettings.NtbIUsername;
                string wachtwoord = HreSettings.NtbIPassword;
                // Creates the post data for the POST request (fiddler: gebruikersnaam=SWW&wachtwoord=18jan2012&Inloggen=True&tijdverschil=-60)
                string postData = ("gebruikersnaam=" + gebruikersnaam + "&wachtwoord="+ wachtwoord+"&Inloggen=True&tijdverschil=-60");

                // Create the POST request.
                HttpWebRequest loginRequest = (HttpWebRequest) WebRequest.Create(ntbInschrijvingenStartUrl);
                loginRequest.Method = "POST";

                loginRequest.KeepAlive = true;
                loginRequest.ContentType = "application/x-www-form-urlencoded";
                loginRequest.ContentLength = postData.Length;

                // POST the data.
                using (StreamWriter requestWriter = new StreamWriter(loginRequest.GetRequestStream())) {
                    requestWriter.Write(postData);
                }

                string framesetUrl;

                // Post the request and get the response back.
                using (HttpWebResponse response = (HttpWebResponse) loginRequest.GetResponse()) {

                    if (response.Cookies!=null && response.Cookies.Count>0) {
                        Cookies = response.Cookies;
                    }

                    // In het teruggegeven resultaat request heeft de URL dan een sessie code in de URL parameter 'SID'.
                    // https://mijn.triathlonbond.nl/_interface/frameset.asp?SID={20B12A29-FFA4-4606-B912-5928181C7D4D}
                    // Deze gebruik je in stap 2.

                    framesetUrl = HttpUtility.UrlDecode(response.ResponseUri.AbsoluteUri);
                    ConsoleWrite(string.Format("Frame set URL (to open for manual editing stuff): {0}", framesetUrl));
                    NtbISessionCode = HttpUtility.ParseQueryString(response.ResponseUri.Query, Encoding.UTF8).Get("SID");
                    ConsoleWrite(string.Format("Session ID: {0}", NtbISessionCode));
                    response.Close();
                }

                string currentEvenementNumber = model.EventNumber;

                string currentSerieNumber;
                switch (model.EventNumber) {
                    case SportsEventRepository.H2RE_EVENTNR:
                        currentSerieNumber = SportsEventRepository.H2RE_SERIENR;
                        break;
                    case SportsEventRepository.HRE_SERIENR:
                        currentSerieNumber = SportsEventRepository.HRE_SERIENR;
                        break;
                    case SportsEventRepository.H3RE_SERIENR:
                    default:
                        currentSerieNumber = SportsEventRepository.H3RE_SERIENR;
                        break;
                }
                // I. Overzichtscherm. Voorbeeld URL: https://mijn.triathlonbond.nl/evenementbeheer/inschrijvingen/inschrijvingen_serie_individueel.asp?SID={20B12A29-FFA4-4606-B912-5928181C7D4D}&Serie=4549
                // Create the GET request.
                string overviewUrl = "https://mijn.triathlonbond.nl/evenementbeheer/inschrijvingen/inschrijvingen_serie_individueel.asp?SID="
                    + NtbISessionCode + "&Serie=" + currentSerieNumber; // CurrentSerieNr;

                // Make a GET request and get the response back.
                // HtmlDocument overviewDoc = GetHtmlDocumentFromUrl(overviewUrl);
                HtmlDocument overviewDoc = new HtmlDocument();
                ConsoleWrite(string.Format("Getting Html document from: {0}", overviewUrl));

                HttpWebRequest overviewReq = (HttpWebRequest) WebRequest.Create(overviewUrl);
                if (Cookies!=null && Cookies.Count>0) {
                    overviewReq.CookieContainer.Add(Cookies);
                }
                overviewReq.KeepAlive = true;
                overviewReq.Method = "GET";
                overviewReq.Headers.Add("Authorization: Basic ZGNpOkFpR2g3YWVj");

                using (HttpWebResponse response = overviewReq.GetResponse() as HttpWebResponse) {
                    if (response.Cookies!=null && response.Cookies.Count>0) {
                        Cookies = response.Cookies;
                    }
                    NtbISessionCode = HttpUtility.ParseQueryString(response.ResponseUri.Query, Encoding.UTF8).Get("SID");

                    // Get the response stream
                    StreamReader reader = new StreamReader(response.GetResponseStream());
                    overviewDoc.Load(reader);
                    reader.Close();
                }

                ////////////////////////////// START Evenement screen.
                // Open the evenement once to do some stuff that's apparantly necesary before you can access the entry detail page (setting cookies or something?).
                string evenementUrl = string.Format("https://mijn.triathlonbond.nl/evenementbeheer/evenement.asp?SID={0}&Evenement={1}", NtbISessionCode, currentEvenementNumber);

                // Make a GET request and get the response back.
                // HtmlDocument overviewDoc = GetHtmlDocumentFromUrl(overviewUrl);
                HtmlDocument evenementDoc = new HtmlDocument();
                ConsoleWrite(string.Format("Getting Html document from: {0}", evenementUrl));

                HttpWebRequest evenementReq = (HttpWebRequest) WebRequest.Create(evenementUrl);
                if (Cookies!=null && Cookies.Count>0) {
                    evenementReq.CookieContainer.Add(Cookies);
                }
                evenementReq.KeepAlive = true;
                evenementReq.Method = "GET";

                using (HttpWebResponse response = evenementReq.GetResponse() as HttpWebResponse) {
                    if (response.Cookies!=null && response.Cookies.Count>0) {
                        Cookies = response.Cookies;
                    }

                    // Get the response stream
                    StreamReader reader = new StreamReader(response.GetResponseStream());
                    evenementDoc.Load(reader);
                    reader.Close();
                }

                ////////////////////////////// END evenement.

                // Filter op de 2e geneste <table> in de 2e <table> in de 2e <div> in de <body> van de <html>.
                // HtmlNodeCollection raceEntryRows = doc.DocumentNode.SelectSingleNode("//body").SelectNodes("div")[1].SelectNodes("table")[1].SelectNodes("table")[1].SelectNodes("tr");
                HtmlNodeCollection raceEntryRows = overviewDoc.DocumentNode.SelectNodes("/html/body/div[2]/table/tr[2]/td/table/tr");

                raceEntryRows.Remove(raceEntryRows.ElementAt(0));
                List<InschrijvingModel> raceEntries = new List<InschrijvingModel>(raceEntryRows.Count);

                int counter = 1;

                foreach (HtmlNode raceEntryRow in raceEntryRows) {
                    InschrijvingModel raceEntry = new InschrijvingModel();

                    raceEntry.DateFirstSynchronized = DateTime.Now;

                    // Pak binnen elke TR even van de 7e td de innerHtml. Dit is de inschrijfdatum; en wel in het volgende format: 3-7-2012 23:03:15.
                    string registrationsDateAsString = raceEntryRow.SelectSingleNode("./td[7]").InnerHtml;
                    raceEntry.RegistrationDate = DateTime.Parse(registrationsDateAsString, CultureInfo.CreateSpecificCulture("nl-NL")); // "dd-MM-yyyy hh:mm:ss"

                    // Daarin neem je de 2e tot en met laatste <tr> (1e is header) en daarin telkens de waarde van het 'onclick' attribuut en wel de waarde tussen de aanhalingstekens (') binnen de Open functie.
                    // bijvoorbeeld: Open('inschrijvingen_serie_detail_individueel.asp?SID={7D72F8DA-7E50-46AC-B22E-81A638FB3171}&Inschrijving=81836');
                    // Regex re = new Regex(@"\'(.*?)\'");
                    string onClickValue = raceEntryRow.Attributes["onclick"].Value;
                    string entryUrlPostfix = Regex.Match(onClickValue, @"\'(.*?)\'").ToString();
                    entryUrlPostfix = entryUrlPostfix.Substring(1, entryUrlPostfix.Length-2);

                    string externalInschrijvingsId = HttpUtility.ParseQueryString(entryUrlPostfix, Encoding.UTF8).Get("Inschrijving");
                    raceEntry.ExternalIdentifier = externalInschrijvingsId;

                    raceEntry.ExternalEventIdentifier = currentEvenementNumber;
                    raceEntry.ExternalEventSerieIdentifier = currentSerieNumber;

                    // Deze pagina open je voor alle rijen (GET request) door het achter de URL te plakken.
                    // Voorbeeld URL: https://mijn.triathlonbond.nl/evenementbeheer/inschrijvingen/inschrijvingen_serie_detail_individueel.asp?SID={7D72F8DA-7E50-46AC-B22E-81A638FB3171}&Inschrijving=94938
                    string entryUrl = "https://mijn.triathlonbond.nl/evenementbeheer/inschrijvingen/" + entryUrlPostfix;

                    ConsoleWrite(string.Format("Getting Html document for entry {0} of {1} from: {2}", counter, raceEntryRows.Count, entryUrl));

                    HtmlDocument entryDoc = new HtmlDocument();
                    HttpWebRequest entryReq = (HttpWebRequest) WebRequest.Create(entryUrl);
                    if (Cookies!=null && Cookies.Count>0) {
                        entryReq.CookieContainer.Add(Cookies);
                    }

                    entryReq.KeepAlive = true;
                    entryReq.Method = "GET";
                    // entryReq.Headers.Add("Authorization: Basic ZGNpOkFpR2g3YWVj");
                    loginRequest.Referer=overviewUrl;
                    // entryReq.Credentials = myCache;

                    using (HttpWebResponse response = entryReq.GetResponse() as HttpWebResponse) {
                        // Get the response stream
                        StreamReader reader = new StreamReader(response.GetResponseStream());
                        if (response.Cookies!=null && response.Cookies.Count>0) {
                            Cookies = response.Cookies;
                        }

                        entryDoc.Load(reader);
                        reader.Close();
                    }

                    // II. Skrape van elke pagina dan de gegevens zoals hieronder gegeven.
                    // Hieruit pak je de <table> uit de tweede <div> in de <body> van de <html>.
                    // Hieruit pak je de 3e tot en met de laatste <tr>.
                    HtmlNodeCollection raceEntryDetails = entryDoc.DocumentNode.SelectNodes("/html/body/div[2]/table/tr");

                    // A. Uit de 3e en 4e <tr>'s pak je telkens de content die staat tussen de tweede <td> en </td> en de vierde <td> en </td>. Dan krijg je achtereenvolgens:
                    // 1. Voornaam, Geboortedatum.
                    raceEntry.Voornaam = raceEntryDetails[2].SelectNodes("./td[2]").First().InnerText.TrimThisShit();
                    string geboorteDatum = raceEntryDetails[2].SelectNodes("./td[4]").First().InnerText.TrimThisShit();
                    raceEntry.GeboorteDatum = DateTime.Parse(geboorteDatum); // CultureInfo.CreateSpecificCulture("nl-NL")

                    // 2. Tussenvoegsel, Licentienummer.
                    raceEntry.Tussenvoegsel = raceEntryDetails[3].SelectNodes("./td[2]").First().InnerText.TrimThisShit();
                    raceEntry.LicentieNummer = raceEntryDetails[3].SelectNodes("./td[4]").First().InnerText.TrimThisShit();

                    // B. In de 5e <tr> pak je uit de tweede <td>
                    // 3. Achternaam.
                    raceEntry.Achternaam = raceEntryDetails[4].SelectSingleNode("./td[2]").InnerText.TrimThisShit();

                    // In de 3e <td> van deze zelfde 5e <tr> zit daarna een geneste <table> met optionele gegevens (id=optioneel) in de 2e tot en met 5e <tr>.
                    // Uit de <tr> pak je telkens de 2e <td> voor achtereenvolgens:
                    // 4. ChampionChip nummer.
                    raceEntry.MyLapsChipNummer = raceEntryDetails[4].SelectSingleNode("./td[3]/table/tr[2]/td[2]").InnerText.TrimThisShit();

                    // 5. Maat T-shirt
                    raceEntry.MaatTshirt = raceEntryDetails[4].SelectSingleNode("./td[3]/table/tr[3]/td[2]").InnerText.TrimThisShit();

                    // 6. Aanmelden Nieuwsbrief
                    raceEntry.Newsletter = raceEntryDetails[4].SelectSingleNode("./td[3]/table/tr[4]/td[2]").InnerText.TrimThisShit()=="Ja";

                    // 7. Interesse in overnachten na de wedstrijd
                    raceEntry.Camp = raceEntryDetails[4].SelectSingleNode("./td[3]/table/tr[5]/td[2]").InnerText.TrimThisShit()=="Ja";

                    // C. In de 10 <tr>'s van de zesde en tot en met de laatste - 16e - <tr> pak je telkens de content die staat tussen de 2e <td> en </td>. Dan krijg je achtereenvolgens:
                    // 8. Geslacht.
                    raceEntry.Geslacht = raceEntryDetails[5].SelectSingleNode("./td[2]").InnerText.TrimThisShit();

                    // 9. Straat en huisnummer (huisnummer gescheiden door &nbsp, spaties in straat zijn gewoon spaties).
                    string straatEnHuisnummer = raceEntryDetails[6].SelectSingleNode("./td[2]").InnerText.Trim();
                    const string straatEnHuisnummerSeperator = "&nbsp;";
                    int straatEnHuisnummerSeperatorIndex = straatEnHuisnummer.IndexOf(straatEnHuisnummerSeperator);
                    raceEntry.Straat = straatEnHuisnummer.Substring(0, straatEnHuisnummerSeperatorIndex);
                    string huisnummerEnToevoeging = straatEnHuisnummer.Substring(straatEnHuisnummerSeperatorIndex+straatEnHuisnummerSeperator.Length, straatEnHuisnummer.Length-(raceEntry.Straat.Length+straatEnHuisnummerSeperator.Length));
                    const string huisnummerEnToevoegingSeperator = "-";
                    int huisnummerEnToevoegingSeperatorIndex = huisnummerEnToevoeging.IndexOf(huisnummerEnToevoegingSeperator);
                    if (huisnummerEnToevoegingSeperatorIndex>0) {
                        raceEntry.Huisnummer = huisnummerEnToevoeging.Substring(0, huisnummerEnToevoegingSeperatorIndex);
                        raceEntry.HuisnummerToevoeging = huisnummerEnToevoeging.Substring(huisnummerEnToevoegingSeperatorIndex+huisnummerEnToevoegingSeperator.Length, huisnummerEnToevoeging.Length-(raceEntry.Huisnummer.Length+huisnummerEnToevoegingSeperator.Length));
                    } else {
                        raceEntry.Huisnummer = huisnummerEnToevoeging;
                        raceEntry.HuisnummerToevoeging = string.Empty;
                    }
                    // 10. Postcode.
                    raceEntry.Postcode = raceEntryDetails[7].SelectSingleNode("./td[2]").InnerText.TrimThisShit();

                    // 11. Woonplaats+.
                    raceEntry.Woonplaats = raceEntryDetails[8].SelectSingleNode("./td[2]").InnerText.TrimThisShit();

                    // 12. Land.
                    raceEntry.Land = raceEntryDetails[9].SelectSingleNode("./td[2]").InnerText.TrimThisShit();

                    // 13. Telefoon.
                    raceEntry.Telefoon = raceEntryDetails[10].SelectSingleNode("./td[2]").InnerText.TrimThisShit();

                    // 14. E-mail.
                    raceEntry.Email = raceEntryDetails[11].SelectSingleNode("./td[2]").InnerText.TrimThisShit();
                    raceEntry.UserName = raceEntry.Email;

                    // 15. Opmerkingen tbv speaker.
                    raceEntry.OpmerkingenTbvSpeaker = raceEntryDetails[12].SelectSingleNode("./td[2]").InnerText.TrimThisShit();

                    // 16. Opmerkingen aan organisatie.
                    raceEntry.OpmerkingenAanOrganisatie = raceEntryDetails[13].SelectSingleNode("./td[2]").InnerText.TrimThisShit();

                    // 17. Deelnamebedrag.
                    string deelnamebedragAsString = raceEntryDetails[14].SelectSingleNode("./td[2]").InnerText;
                    string deelnamebedragKaleString = deelnamebedragAsString.Replace("&euro;", "").Replace(",", "").TrimThisShit();
                    int deelnamebedragAsInt;
                    bool result = int.TryParse(deelnamebedragKaleString, out deelnamebedragAsInt);
                    if (result) {
                        raceEntry.InschrijfGeld = deelnamebedragAsInt;
                    }

                    // Save the entry (Determine if the entry aready exists using externalIdentifier and then update, otherwise insert).
                    InschrijvingenRepository.SaveEntry(raceEntry, currentEvenementNumber, true, model.OverrideLocallyUpdated);
                    raceEntries.Add(raceEntry);

                    if (counter>=maxNumberOfItemsToScrape) {
                        ConsoleWrite(string.Format("Stopping scraping after {0} entries.", counter));
                        break;
                    }
                    counter++;

                }

            } catch (WebException ex) {
                using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream())) {
                    string str = reader.ReadToEnd();
                    ConsoleWrite(string.Format("Error! Response: {0}", str));
                }
            }

            return View("Index", model);
        }
Exemplo n.º 4
0
 public ActionResult Index()
 {
     Initialise(AppConstants.MeedoenOverzicht);
     InschrijvingenModel model = new InschrijvingenModel();
     return View(model);
 }
Exemplo n.º 5
0
        public ActionResult DownLoadSpeakerList(InschrijvingenModel model)
        {
            string filename = string.Format("HRE-Spkr-{0}-{1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString().Replace(":", ""));
            MemoryStream ms = CreateExcelFile(filename, true);

            // Return the memorystream (IF something was created).
            if (ms != null) {
                // Rewind the memory stream to the beginning.
                ms.Seek(0, SeekOrigin.Begin);
                return File(ms, @"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", filename + ".xlsx");
            } else {
                return View("Index");
            }
        }
Exemplo n.º 6
0
        public ActionResult DeleteTestUser(InschrijvingenModel model)
        {
            int eventId = SportsEventDal.GetByExternalId(model.EventNumber).ID;
            int userId = model.UserIdToDelete;
            SportsEventParticipationDal participation = SportsEventParticipationDal.GetByUserIdEventId(userId, eventId);
            if (participation!=null) {
                participation.Delete();
                model.Message = string.Format("Inschrijving van gebruiker {0} voor event {1} verwijderd.", userId, eventId);
            }

            return RedirectToAction("Index");
        }