public async Task <IHttpActionResult> Post(LeagueModel model) { //Add New League String compid = model.Competitor.ToString(); var appUser = userRepository.GetMany(u => u.FacebookId == compid).FirstOrDefault(); var creator = userRepository.GetById(model.Creator); var obj = new League { Name = model.Name, Competitor = appUser.UserId, Creator = model.Creator, CreateDate = DateTime.Now.Date, Accepted = 0, TournamentId = 1 }; var league = leagueRepository.Add(obj); unitofWork.SaveChanges(); //Insert Matches for League var matches = matchRepository.GetMany(m => m.TournamentId == 1).ToList(); foreach (var match in matches) { LeagueMatch lm = new LeagueMatch() { LeagueId = league.LeagueId, MatchDate = match.MatchDate, TeamId1 = match.TeamId1, TeamId2 = match.TeamId2, Toss = 0, TossDone = false, Venue = match.Venue, MatchId = match.MatchId, TeamName1 = teamRepository.GetById(match.TeamId1).ShortName, TeamName2 = teamRepository.GetById(match.TeamId2).ShortName }; leagueMatchRepository.Add(lm); } unitofWork.SaveChanges(); Notification notif = new Notification() { Title = creator.UserName, Message = "New Challange from " + creator.UserName + "- " + league.Name, Payload = new ChallangePayload() { leagueId = league.LeagueId, Tag = "LEAGUE_CHALLANGE", userId = model.Creator } }; NotificationHelper.sendNotification(appUser.DeviceToken, notif); return(Ok(league)); }
public void Seed() { var leagueMatch = new LeagueMatch() { idLeague = 1, idMatch = 1 }; _session.Save(leagueMatch); }
public AuthModel addLM([FromBody] LeagueMatchModel model) { LeagueMatch lm = new LeagueMatch(); lm.Id = model.id; lm.idLeague = model.idLeague; lm.idMatch = model.idMatch; _writeOnlyRepository.Create(lm); var authModel = new AuthModel { }; return(authModel); }
private static MatchContribution GetWinningFighterResult(LeagueMatch o) { return(o.Match.MatchContributions.FirstOrDefault(c => c.HasWon)); }