public IHttpActionResult Get(int id, int unionId) { var refServ = new RefereeSevice(); var seasonServ = new SeasonsRepo(); int?seasonId = seasonServ.GetLasSeasonByUnionId(unionId); var gamesList = refServ.GetRefereeGames(id, seasonId); var vm = new RefereeViewModel(); if (gamesList.Count > 0) { vm.LiveGame = gamesList.FirstOrDefault(t => t.Status == GameStatus.Started); vm.ClosedGames = gamesList.Where(t => t.Status != GameStatus.Started && t.Status != GameStatus.Next) .OrderBy(t => t.StartDate) .ToList(); if (vm.ClosedGames != null && vm.ClosedGames.Count > 0) { vm.CloseGame = vm.ClosedGames.Last(); vm.NextGames = gamesList.Where(t => t.StartDate > vm.CloseGame.StartDate && t.Status != GameStatus.Started) .OrderBy(t => t.StartDate) .ToList(); } else { vm.NextGames = gamesList.Where(t => t.Status != GameStatus.Started) .OrderBy(t => t.StartDate) .ToList(); } } return(Ok(vm)); }
public IHttpActionResult Get(int id, int?unionId = null) { SeasonsRepo seasonsRepo = new SeasonsRepo(); int? seasonId = unionId != null?seasonsRepo.GetLastSeasonByCurrentUnionId(unionId.Value) : (int?)null; var clubInfo = ClubService.GetClub(id, seasonId); return(Ok(clubInfo)); }
public IHttpActionResult GetUserInfo(int?unionId = null) { var usr = CurrentUser; if (usr == null) { return(NotFound()); } SeasonsRepo seasonsRepo = new SeasonsRepo(); int? seasonId = unionId != null?seasonsRepo.GetLastSeasonByCurrentUnionId(unionId.Value) : (int?)null; var vm = new UserInfoViewModel { Id = usr.UserId, UserName = usr.UserName, Email = usr.Email, FullName = usr.FullName, Role = usr.UsersType.TypeRole, Image = usr.Image, }; if (usr.UsersJobs != null && usr.UsersJobs.Count > 0) { //vm.UserJobs = usr.UsersJobs.Select(x => x.JobId).ToList(); vm.UserJobs = usr.UsersJobs.Select(x => new UserJobDetail() { UserId = x.Id, JobId = x.JobId, JobName = (x.Job == null ? null : x.Job.JobName), JobRoleId = (x.Job == null || x.Job.RoleId == null ? 0 : (int)x.Job.RoleId), JobRoleName = (x.Job == null || x.Job.JobsRole == null ? null : x.Job.JobsRole.RoleName), JobRolePriority = (x.Job == null || x.Job.JobsRole == null ? 0 : x.Job.JobsRole.Priority), LeagueId = x.LeagueId, LeagueName = (x.League == null ? null : x.League.Name), TeamId = x.TeamId, TeamName = (x.Team == null ? null : x.Team.Title) }).ToList(); } var teamsRepo = new TeamsRepo(); if (User.IsInRole(AppRole.Fans)) { vm.Teams = teamsRepo.GetFanTeams(usr.UserId, seasonId); } else if (User.IsInRole(AppRole.Players)) { vm.Teams = teamsRepo.GetPlayerTeams(usr.UserId, seasonId); } else if (User.IsInRole(AppRole.Workers)) { vm.Teams = usr.UsersJobs.Select(x => new DataService.DTO.TeamDto() { TeamId = (x.Team == null ? 0 : x.Team.TeamId), Title = (x.Team == null ? null : x.Team.Title), LeagueId = (x.LeagueId == null ? 0 : (int)x.LeagueId), Logo = (x.Team == null ? null : x.Team.Logo), SeasonId = (x.SeasonId == null ? 0 : x.SeasonId) }).ToList(); } return(Ok(vm)); }
public SeasonsController() { _seasonsRepository = new SeasonsRepo(); _leagueRepo = new LeagueRepo(); }