protected void btnSubmit_Click(object sender, EventArgs e) { Model.Team u = new Model.Team { Team_Title = this.txtTitle.Text.Trim(), Team_Image = upFileName(this.FileUpload1, "../../upload/Team/"), Team_Content = this.txtContent.Text, }; var res = TeamSvc.Add(u); ReturnMsg rm = res > 0 ? new ReturnMsg() { Code = StatusCode.OK, Message = "新增用户信息成功", Data = null } : new ReturnMsg() { Code = StatusCode.Error, Message = "新增用户信息失败", Data = null }; Session["Msg"] = rm; //用于传递执行信息的 Response.Redirect("Team_List.aspx"); }
public static Team GetOrInsertByName(this IRepositoryAsync<Team> repository, string name) { var teams = repository.Queryable(); var singleteam = teams.FirstOrDefault(item => item.Name.ToLower() == name.ToLower()); if (singleteam == null) { singleteam = new Team() {Name = name}; singleteam.ObjectState=ObjectState.Added; //repository.Insert(singleteam); } return singleteam; }
private static void SetFixtures(Series series, int season, IEnumerable<SeriesFixturesSummaryEntity> seriesFixturesResult) { var teams = new List<Team>(); var seriesFixture = series.SeriesFixtures; foreach (var match in seriesFixturesResult.First(s => s.LeagueLevelUnitID == series.HtSeriesId).Matches) { var fixture = seriesFixture.FirstOrDefault(f => f.HtMatchId == match.MatchID); if (fixture == null) { fixture = new SeriesFixture(); var homeTeam = teams.FirstOrDefault(t => t.TeamId == match.HomeTeamID); if (homeTeam == null) { homeTeam = new Team { Country = series.Country, TeamId = match.HomeTeamID, TeamName = match.HomeTeamName }; teams.Add(homeTeam); } var awayTeam = teams.FirstOrDefault(t => t.TeamId == match.AwayTeamID); if (awayTeam == null) { awayTeam = new Team { Country = series.Country, TeamId = match.AwayTeamID, TeamName = match.AwayTeamName }; teams.Add(awayTeam); } fixture.HtMatchId = match.MatchID; fixture.AwayTeam = awayTeam; fixture.HomeTeam = homeTeam; fixture.MatchDate = match.MatchDate; fixture.MatchRound = match.MatchRound; fixture.Season = (short)season; series.AddSeriesFixture(fixture); } fixture.AwayGoals = (short?)match.AwayGoals; fixture.HomeGoals = (short?)match.HomeGoals; } }