/ContestWinnerFromCsv

A NuGet package to pick contest winners from a CSV file exported from Form Services (Google Froms, TypeForm, etc)

Primary LanguageC#MIT LicenseMIT

Contest Winner From CSV

Project Status GitHub last commit Build Status

Installation

Package Manager
Install-Package ContestWinnerFromCsv -Version 1.0.0

.Net CLI
dotnet add package ContestWinnerFromCsv --version 1.0.0

Package Reference
<PackageReference Include="ContestWinnerFromCsv" Version="1.0.0" />

Paket CLI
paket add ContestWinnerFromCsv --version 1.0.0

Usage

App Settings

Add appsettings.json in the same directory as your application or add the following section to your pre-existing file.

{
  "Settings": {
    "CsvLocation": "",
    "NumberOfWinners": 1,
    "StartDateTimeOfContest": "10/20/2020",
    "EndDateTimeOfContest": "11/20/2020"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information"
    }
  }
}

Note: CsvLocation is for future use and is not currently used for anything.

Calling Contest Winner

Within ContestWinnerFromCsv.FormServices you'll find a list of currently supported services and their maps.

using ContestWinnerFromCsv;
using ContestWinnerFromCsv.FormServices;

...

var path = @"c:/path/to.csv";
var contest = new ContestWinner<GoogleFormsCsvModel, GoogleFormsCsvMap>(path);
var entries = contest.GetEntries().ToList();
var results = contest.PickWinners();

Adding your own model and mappings

If you want to add a Form Service that the library doesn't currently have all you have to do is inherit ICsvModel then provide a CsvHelper ClassMap.

Note: You don't have to set the TimeStamp in SetTimeStampAndValidate if your mapping can correctly map to DateTime.

For an example of this take a look at the GoogleFormsCsvModel. Unfortunately Google Forms does not use a standard TimeStamp in their csv export.

Contributing

License

MIT