protected void LoadSeasons() { using (var context = new CSBCDbContext()) { var rep = new SeasonRepository(context); var seasons = rep.GetSeasons(CompanyId).OrderByDescending(s => s.FromDate).ToList(); ddlSeasons.DataValueField = "SeasonID"; ddlSeasons.DataTextField = "Description"; ddlSeasons.DataSource = seasons; ddlSeasons.DataBind(); } }
public List<SelectSeasonVM> GetRecords(int companyId) { var rep = new SeasonRepository(new Core.Data.CSBCDbContext()); IQueryable<Season> seasons = rep.GetSeasons(companyId); var seasonsVm = new List<SelectSeasonVM>(); foreach (Season season in seasons) { var vm = new SelectSeasonVM(); vm.SeasonID = season.SeasonID; vm.Description = season.Description; vm.FromDate = (DateTime)season.FromDate; vm.ToDate = (DateTime)season.ToDate; vm.CurrentSeason = season.CurrentSeason == null ? false : (bool)season.CurrentSeason; vm.CurrentSchedule = season.CurrentSchedule == null ? false : (bool) season.CurrentSchedule; vm.CurrentSignUps = season.CurrentSignUps == null ? false : (bool)season.CurrentSignUps; seasonsVm.Add(vm); } return seasonsVm.OrderByDescending(s => s.FromDate).ToList(); }
public void GetSeasonsFromRepository() { var rep = new SeasonRepository(context); var seasons = rep.GetSeasons(1); Assert.IsTrue(seasons.Count<Season>() > 0); }