Exemplo n.º 1
0
            /// <summary>
            /// This method runs when the request is sent through Mediatr.
            /// It first parses the CSV, then creates the venues, then uploads any venues which don't exist.
            /// In a full implementation that would allow admins to upload CSVs, this would contain data validation on the CSV and
            /// return information on what has and has not been uploaded.
            /// However for the sake of this exercise this has been left out in order to focus on other areas.
            /// </summary>
            /// <param name="request"></param>
            /// <param name="token"></param>
            /// <returns></returns>
            public async Task <Unit> Handle(Request request, CancellationToken token)
            {
                var parsedCsv = ParseCsv(request.Csv);
                var venues    = CreateVenues(parsedCsv);

                await repo.BatchUpsertVenues(venues, token);

                return(Unit.Value);
            }