Skip to content

Creating Competition

Julien Grimault edited this page Jan 27, 2014 · 41 revisions

this is a checklist of the steps that need to be performed when creating a new competition.

Create Model in DB

Generate rows in the database

Invoke the command line tool TH_UTIL.exe build-competition with the options that you need. A typical invocation is shown below:

TH_UTIL.exe build-competition --db DEV --provider-name Dummy --start-date  01-23-2014 --number-of-weeks 4
                              --number-of-months 1 --prize-currency S$ --weekly-prizes 500 300 300 100 100
                              --monthly-prizes 2500 1500 1000 --country-codes SG TH

Note that the date must be entered in the format mm/dd/yyyy.

This will create the elements needed to run the competition in the database. Use TH_UTIL.exe build-competition to see the help menu and find more details about the various options.

Verify Entities creation

The command line tool should have inserted the following elements in the database:

  • 1 row in Provider
  • 1 row in Competition + 1 corresponding row in LeaderboardDef for each week
  • for each weekly Competition created above, 1 Prize row for each prize given in the --weekly-prize list.
  • 1 row in Competition + 1 corresponding row in LeaderboardDef for each month
  • for each monthly Competition created above, 1 Prize row for each prize given in the --monthly-prize list.
  • 1 ProviderCountry row for each country code given.
  • 5 ProviderPage rows with the following name: landing, enrollment, terms, rules, outbound. They are used for analytics purpose.
  • 1 Advertisement row for the Provider created above, the outbound name default to the Provider name.

The prize currency option is used to format the message in the Prize and Competition row.

Tweak marketing message

You will need to edit manually the raw of the newly created Provider to enter the marketing messages.

Assets

Copy Assets

There is a set of generic assets located at TH_API/WebClient/competitionPages/img/brokerCo

There is a script that copy the list of assets under brokerCo and rename them so that any brokerco occurrence in the file names is replaced with MyCompetition. The script takes 2 input parameters

  • the name of the new competition MyCompetition
  • the path to the directory containing the brokerCo image directory.
./competition-copy-assets.sh MyCompetition ~/code/TH_SVR/TH_API/WebClient/competitionPages/img

You now should have a new directory MyCompetition containing the assets from the brokerCo folder but with any reference to brokerCo in the file name replaced with MyCompetition.

Add Assets to VS Solution

The new assets are now on disk at the right location, we need to add them to the visual studio solution. First make sure you enable the Project > Show All Files option. In the solution explorer, right click on the folder TH_API/WebClient/competitionPages/img/{MyCompetition} and choose Include In Project.

HTML pages

You first need to find out what is the id of the Provider row that was created for the competition in the first step.

Copy Pages

All the html pages specific to competitions are located at TH_API/Views/CompetitionPages. For each type of page, there is a container page which renders a specific template based on the provider. For instance, for the BrokerCo provider (id=17), the Rules.cshtml page will render the template Rules/_RulesProvider17.cshtml.

There is a script that copy the brokerCo pages and rename them for the new provider we are creating. The script is invoked as follow:

./competition-copy-html.sh ID NAME PATH OUTBOUND_NAME

where:

  • id is the id of the new provider we created in the earlier step
  • NAME is the name of the new provider we created in the earlier step
  • PATH is the path to the directory containing the competition html pages.
  • OUTBOUND_NAME is a list of the outbound screen to create - there should be 1 outbound name per advertisement created in the first step. the name of the outbound page to create should match the outboundName column on the Advertisement entity created in the first step.
./competition-copy-html.sh 123 MyCompetition ~/code/TH_SVR/TH_API/Views/CompetitionPages MyCompetition

Add Pages to VS solution

The new assets are now on disk at the right location, we need to add them to the visual studio solution. In the solution explorer right click on the folders where the new files where created and add them using Add > Existing Item.

Creating missing classes in VS

You need to create 2 C# classes that represent the forms being sent to the server when the user signs up for the competition or fill in an outbound form.

CompetitionFormDTO

Create a subclass of CompetitionFormDTO, the existing subclasses are located at TH_COMMON/DTOs/Competitions/Enroll. You will need to modify the switch statement to take into account the new provider in the ProviderExtensions.cs

You will also need to update the _EnrollmentFormProviderXX.cshtml that was created in the previous step to integrate with the new form. Pay attention to the @model directive and any method used to build the form dynamically: here and here. Of course, you can also totally change the html page and create whatever properties are necessary in your DTO class.

Tradable Securities

You will need to update the query fetching the tradable securities for the new Provider in ProviderExtension.cs

OutboundFormDTO

Create a subclass of OutboundFormDTO, the existing subclasses are located at TH_COMMON/DTOs/Competitions/Outbound. You will need to modify the switch statement to take into account the new provider in the AdvertisementExtension.cs

You will also need to update the _OutboundProviderXX_Outbound_YY.cshtml that was created in the previous step to integrate with the new form. Pay attention to the @model directive. Of course, you can also totally change the html page and create whatever properties are necessary in your DTO class.

Turn it on!

set the new Provider active flag to true.

update Provider set active = 1 where id = XXX

Clone this wiki locally