示例#1
0
 public bool DeleteSeason(Models.Season season)
 {
     if (season == null)
     {
         return(false);
     }
     _unitOfWork.SeasonRepository.Delete(season);
     _unitOfWork.Save();
     return(true);
 }
示例#2
0
        public static void ParseResultsDirectory(racewranglerContext context)
        {
            var di = new DirectoryInfo(@"..\results");

            foreach (var d in di.EnumerateDirectories())
            {
                var season = (from s in context.Seasons
                              where s.Year == int.Parse(d.Name)
                              select s).FirstOrDefault();

                // Don't continuously add seasons, use an existing one if possible!
                if (season == default(Season))
                {
                    season = new Models.Season()
                    {
                        Year         = int.Parse(d.Name),
                        Competitions = new List <Competition>()
                    };
                }

                // Now check each file in the directory to see if it has been loaded
                // If not, load it into the database!
                foreach (var f in d.EnumerateFiles())
                {
                    var fileLoaded = (from c in context.Competitions
                                      where c.ResultsSource == f.FullName
                                      select c).Any();
                    if (!fileLoaded)
                    {
                        var comp = new Models.Competition()
                        {
                            Entrants = new List <RaceEntry>()
                        };

                        ParseCompetition(context, comp, f);

                        comp.ResultsSource = f.FullName;

                        season.Competitions.Add(comp);
                    }
                }

                context.Seasons.Update(season);
            }

            context.SaveChanges();

            return;
        }
示例#3
0
        public async Task <IHttpActionResult> Get(string seasonReference)
        {
            bool converts = int.TryParse(seasonReference, out int seasonId);

            if (converts == false)
            {
                return(BadRequest());
            }

            DatabaseAccess.ExternalModel.Season databaseSeason = await _seasonRepository.GetSeasonAsync(seasonId);

            Models.Season season = Models.Season.Convert(databaseSeason);

            season.Link = Url.Content("~/") + "season/" + databaseSeason.SeasonId;

            return(Ok(season));
        }
示例#4
0
 public bool EditSeason(Models.Season season)
 {
     _unitOfWork.SeasonRepository.Edit(season);
     _unitOfWork.Save();
     return(true);
 }
示例#5
0
 public bool AddSeason(Models.Season season)
 {
     _unitOfWork.SeasonRepository.Add(season);
     _unitOfWork.Save();
     return(true);
 }