public IHttpActionResult Get() { var season = _seasonRepository.GetAll().Cast <Season>(); if (season == null || !season.Any()) { return(NotFound()); } return(Ok(season)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var seasonRepository = new SeasonRepository(); var seasons = seasonRepository.GetAll(); SeasonList.DataSource = seasons; SeasonList.DataValueField = "Id"; SeasonList.DataTextField = "Name"; SeasonList.DataBind(); var currentSeason = seasonRepository.GetCurrent(); SeasonList.SelectedValue = currentSeason.Id.ToString(); var races = currentSeason.Races; RaceList.DataSource = races; RaceList.DataValueField = "Id"; RaceList.DataTextField = "Name"; RaceList.DataBind(); } }
public ActionResult Delete(int seasonId) { var seasonRepo = new SeasonRepository(); var result = new ApiResult(); try { var season = seasonRepo.GetAll().SingleOrDefault(sr => sr.SeasonId == seasonId); if (null != season) { season.IsActive = false; seasonRepo.Save(season); } result.Description = "Season successfully deleted!"; result.Success = true; } catch (Exception e) { result.Description = "Failed to delete season"; result.Success = false; } return this.ToJson(result); }