public CricketMatch CreateInstanceOfCricketMatch(Match match) { var cricketMatch = new CricketMatch(match); if (this.Innings == null) { this.Innings = new List <Innings>(); } this.Toss = new Toss(); if (match != null) { this.MatchId = match.MatchId; this.Team1Id = match.Team1Id; this.Team2Id = match.Team2Id; this.FormatType = match.FormatType; this.WideValue = match.WideValue; this.NoBallValue = match.NoBallValue; this.NumberOfPlayersPerTeam = match.NumberOfPlayersPerTeam; this.MatchStatus = match.MatchStatus; var teams = Data.Teams.GetTeams(); var crTeam1 = new CricketTeam(teams.FirstOrDefault(x => x.Id == match.Team1Id)); var crTeam2 = new CricketTeam(teams.FirstOrDefault(x => x.Id == match.Team2Id)); crTeam1.Players = Players.GetPlayers().Where(x => x.PlayerRole.TeamId == match.Team1Id).Select(y => new CricketPlayer(y)).ToList(); crTeam2.Players = Players.GetPlayers().Where(x => x.PlayerRole.TeamId == match.Team2Id).Select(y => new CricketPlayer(y)).ToList(); this.Teams = new List <CricketTeam> { crTeam1, crTeam2 }; this.Name = crTeam1.Name + " v " + crTeam2.Name; } return(cricketMatch); }
public IActionResult AddCricketTeam([FromForm] CricketTeam team) { var test = _service.AddCricketTeam(team); if (test) { return(Ok(test)); } else { return(BadRequest("error")); } }
public Boolean UpdateCricketTeam(CricketTeam team) { try { _context.Entry(team).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(true); } catch { return(false); } }
public Boolean AddCricketTeam(CricketTeam team) { try { _context.CricketTeams.Add(team); _context.SaveChanges(); return(true); } catch { return(false); } }
public IActionResult UpdateCricketTeam([FromForm] CricketTeam team) { try { var test = _service.UpdateCricketTeam(team); if (test) { return(Ok()); } else { return(BadRequest()); } } catch { return(BadRequest()); } }
public Boolean UpdateCricketTeam(CricketTeam team) { return(_service.UpdateCricketTeam(team)); }
public Boolean AddCricketTeam(CricketTeam team) { return(_service.AddCricketTeam(team)); }