Exemplo n.º 1
0
        public string ErrorMessageSavingDataToDb(string raceResultsArchiveId, string raceResultsArchiveTitle, DataTable grandPrixResults)
        {
            var errorMessage = string.Empty;

            try
            {
                using (var context = new GrandPrixResultsContext(ConnectionString))
                {
                    context.GrandPrix.Add
                        (new GrandPrix
                    {
                        GrandPrixId           = raceResultsArchiveId,
                        GrandPrixResultsTitle = raceResultsArchiveTitle
                    });

                    foreach (DataRow dataRow in grandPrixResults.Rows)
                    {
                        context.GrandPrixResults.Add(new GrandPrixResults(raceResultsArchiveId, dataRow));
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                errorMessage = exception.Message;
            }

            return(errorMessage);
        }
Exemplo n.º 2
0
 public bool IsRaceResultsExistsInDbByIdCheck(string raceResultsArchiveId)
 {
     using (var context = new GrandPrixResultsContext(ConnectionString))
         return(context.GrandPrix.Any(grandPrix => grandPrix.GrandPrixId == raceResultsArchiveId));
 }