public async Task <IActionResult> UpdateTeam([FromBody] TeamDTO team) { try { await _teamService.UpdateTeam(team).ConfigureAwait(false); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public List <BoardDTO> GetAllUsersBoards(TeamDTO userTeam) { Team teamEntity = TeamRepos.Find(userTeam.Id); List <Board> boards = new List <Board>(); foreach (var b in teamEntity.Boards) { boards.Add(b); } Mapper.Reset(); Mapper.Initialize(cfg => cfg.CreateMap(typeof(List <Board>), typeof(List <BoardDTO>))); return((List <BoardDTO>)Mapper.Map(boards, typeof(List <Board>), typeof(List <BoardDTO>))); }
public async Task <TeamDTO> AddTeam(TeamDTO teamDTO) { var team = _mapper.Map <Team>(teamDTO); try { return(_mapper.Map <TeamDTO>(await _teamRepository.AddTeam(team))); } catch (DatabaseConstraintException) { throw new TeamNameAlreadyExistsException(); } }
public async Task <ActionResult> GetSpecificTeam(int teamId) { try { TeamDTO team = await _teamService.GetSpecificTeam(teamId); return(Ok(team)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void AddTeamWithoutSufficientPermission() { login = new LoginServicesMock(christina); TeamDTO boca = new TeamDTO() { Name = "Boca", SportName = "Futbol" }; TeamServices services = new TeamServices(login, teamRepository, sportRepository, userRepository); services.CreateTeam(boca); }
public async Task <IActionResult> GetEntityById(int teamId) { try { TeamDTO team = await _teamService.GetEntityById(teamId); return(Ok(team)); } catch (Exception e) { Console.WriteLine(e.Message); return(BadRequest(e.Message)); } }
private static Team convertToEntity(TeamDTO teamDTO) { var team = new Team(); team.record_id = teamDTO.RecordID; team.team_id = teamDTO.TeamID; team.league = teamDTO.League; team.city = teamDTO.City; team.name = teamDTO.Name; team.season_year = teamDTO.SeasonYear; team.season_game_type = teamDTO.SeasonGameType; return(team); }
public void TestInit() { contextFactory = GetContextFactory(); sportRepo = new SportRepository(contextFactory); teamRepo = new TeamRepository(contextFactory); futbol = CreateFutbol(); rugby = CreateRugby(); boca = CreateBocaTeam(); river = CreateTeamThatBelongsInTheB(); sportRepo.Add(new Sport("Futbol")); teamRepo.Add(new Team(boca.Name, new Sport("Futbol"))); teamRepo.Add(new Team(river.Name, new Sport("Futbol"))); login = CreateLoginServices(); }
public TeamDTO CreateTeam(TeamDTO team) { validator.ValidatePermissions(); try { Team domainTeam = teamMapper.Map(team); teamRepository.Add(domainTeam); return(teamMapper.Map(domainTeam)); } catch (DataAccessException e) { throw new ServicesException($"Failure to add team with name {team.Name}.", e); } }
public async Task <TeamDTO> CreateTeam(String teamName, String tagName) { int Id = Invoke("summonerTeamService", "createTeam", new object[] { teamName, tagName }); while (!results.ContainsKey(Id)) { await Task.Delay(10); } TypedObject messageBody = results[Id].GetTO("data").GetTO("body"); TeamDTO result = new TeamDTO(messageBody); results.Remove(Id); return(result); }
public void CreateTeam(TeamDTO teamDTO) { if (teamDTO != null) { TeamDAL team = new TeamDAL { TeamID = teamDTO.TeamID, Name = teamDTO.Name, Project = teamDTO.Project }; _unitOfWork.TeamRepository.Create(team); _unitOfWork.Save(); } }
public async Task <TeamDTO> KickPlayer(Double summonerId, TeamId teamId) { int Id = Invoke("summonerTeamService", "kickPlayer", new object[] { summonerId, teamId.GetBaseTypedObject() }); while (!results.ContainsKey(Id)) { await Task.Delay(10); } TypedObject messageBody = results[Id].GetTO("data").GetTO("body"); TeamDTO result = new TeamDTO(messageBody); results.Remove(Id); return(result); }
public void AddTeamOk() { TeamDTO boca = new TeamDTO { Name = "Boca", SportName = "Futbol" }; TeamServices services = new TeamServices(login, teamRepository, sportRepository, userRepository); services.CreateTeam(boca); IEnumerable <Team> recovered = teamRepository.GetAll(); Assert.AreEqual(1, recovered.ToList().Count); }
public async Task UpdateTeam(TeamDTO teamDTO) { var team = await _repository.Get(teamDTO.Id).ConfigureAwait(false); if (team == null) { throw new Exception($"Not found team with id={team.Id}"); } else { team = _mapper.Map(teamDTO, team); await _repository.Update(team).ConfigureAwait(false); } }
public void Put(TeamDTO teamDTO) { using (var db = new ModelContext()) { Team existingTeam = db.Teams .Where(m => m.Id == teamDTO.Id) .FirstOrDefault(); if (existingTeam != null) { existingTeam.Name = teamDTO.Name; db.SaveChanges(); } } }
public async Task <IActionResult> CreateEntity([FromBody] TeamDTO teamDTO) { try { TeamDTO createdTeam = await _teamService.CreateEntity(teamDTO); return(Ok(createdTeam)); } catch (Exception e) { Console.WriteLine(e.Message); return(BadRequest(e.Message)); } }
public TeamViewModel(TeamDTO t, string editUrl) { TeamId = t.TeamId; NucleoId = t.NucleoId; Name = t.Name; Description = t.Description; Active = t.Active; IsDeleted = t.IsDeleted; CreateBy = t.CreateBy; CreateOn = t.CreateOn; UpdateBy = t.UpdateBy; UpdateOn = t.UpdateOn; EditUrl = editUrl; }
public static TeamDTO registerTeam(string teamCode, string name, string registrationType) { ConvictsContext db = new ConvictsContext(); Team team = new Team(); string returnStatus = "false"; string errorMessage = ""; try { Team found = db.Teams.Find(teamCode); if (found == null) { team.TeamCode = teamCode; team.TeamName = name; team.TeamType = registrationType; team.ModifiedDate = DateTime.Now; team.Total = "0"; team.CreateDate = DateTime.Now; db.Teams.Add(team); db.SaveChanges(); } else { team = found; team.ModifiedDate = DateTime.Now; db.Entry(found).CurrentValues.SetValues(team); db.SaveChanges(); } returnStatus = "true"; } catch (Exception ex) { returnStatus = "false"; errorMessage = ex.Message; } TeamDTO returnobj = new TeamDTO(); returnobj.status = returnStatus; returnobj.errorMessage = errorMessage; returnobj.team = team; return(returnobj); }
public async Task <TeamDTO> AddMemberToTeam(int teamId, int memberId, bool IsTeam) { using (_unitOfWork) { Team team = await _unitOfWork.TeamRepository.GetTeamWithMembers(teamId); Member member; if (IsTeam) { member = await _unitOfWork.TeamRepository.GetTeamWithMembers(memberId); } else { member = await _unitOfWork.UserRepository.FindByID(memberId); } if (team.Members == null) { team.Members = new List <User>(); } foreach (User user in member.GetUsers()) { if (!team.Members.Contains(user)) { team.Members.Add(user); if (user.MyTeams == null) { user.MyTeams = new List <Team>(); } user.MyTeams.Add(team); _unitOfWork.UserRepository.Update(user); await _messageControllerService.SendNotification(user.UserId, "AddToTeamNotification", _mapper.Map <Team, TeamDTO>(team)); } } _unitOfWork.TeamRepository.Update(team); await _unitOfWork.Save(); TeamDTO retTeam = _mapper.Map <Team, TeamDTO>(team); TeamUserListDTO notifyDTO = new TeamUserListDTO() { TeamId = teamId, Users = team.Members.Select(user => _mapper.Map <User, UserBasicDTO>(user)) }; await _messageControllerService.NotifyOnTeamChanges(teamId, "AddMemberToTeam", notifyDTO); return(retTeam); } }
internal static TeamDTO ToDto(Team objet) { TeamDTO retour = new TeamDTO(); if (objet != null) { retour.Id = objet.Id; retour.Label = objet.Label; retour.IsDeleted = objet.IsDeleted; retour.DateCreation = (System.DateTime)objet.DateCreation; retour.DateModification = (System.DateTime)objet.DateModification; } return(retour); }
private async Task <GameDTO> SaveGame(GamePageInformation gameInfo, TeamDTO awayTeam, TeamDTO homeTeam, SeasonDTO season) { GameDTO gameDto = new GameDTO() { AwayTeamId = awayTeam.Id, HomeTeamId = homeTeam.Id, Date = gameInfo.Date, Time = gameInfo.Time, Location = gameInfo.Location, SeasonId = season.Id, CreatedOnUtc = DateTime.Now }; return(await _gameService.Upsert(gameDto)); }
public IHttpActionResult CreateTeam([FromBody] TeamDTO _team) { LeaguesApiController leaguesApiController = new LeaguesApiController(); int leagueId = leaguesApiController.getLeagueIdByTeamId(_team.Id); team t = new team { Name = _team.Name, Description = _team.Description, League = leagueId, Enabled = true, Logo = _team.Logo }; using (var context = new escorcenterdbEntities()) { context.teams.Add(t); context.SaveChanges(); } return(Ok(t)); }
public async Task CreateTeam(TeamDTO team) { if (team == null) { throw new Exception("You can`t create empty team"); } if (await _repository.Get(team.Id).ConfigureAwait(false) != null) { throw new Exception("This team has alredy exist"); } else { await _repository.Create(_mapper.Map <Team>(team)).ConfigureAwait(false); } }
public TeamErrorCodes CreateTeam(TeamDTO teamDTO, string UserID) { var result = teamManagerDB.FindTeamByName(teamDTO.TeamName); if (result != null) { return(TeamErrorCodes.NameAlreadyExists); } teamDTO.TeamID = idGenerator.GenerateID(12); teamManagerDB.CreateTeam(teamDTO); Team team = new Team(teamDTO, source); team.AddPlayer(UserID, TeamRoles.Owner); return(TeamErrorCodes.NoError); }
private bool AlreadyReassign(TeamDTO team) { var teams = _storage.Get <TeamDTO>() .Where(t => t.AssignableID == team.AssignableID) .Where(t => t.RoleName == GetAssigneeRole()) .ToList(); if (teams.Any()) { var oldTeamId = teams.Max(t => t.TeamID); return(oldTeamId > team.ID); } return(false); }
public async Task Get_by_IdAsync_Returns_BadRequest() { //Arrange Mapper.Initialize(config => { config.CreateMap <CreateTeamViewModel, TeamDTO>().ReverseMap(); }); int teamId = 1; TeamDTO expextedTeam = null; _mockFMService.Setup(s => s.GetTeamAsync(teamId)).ReturnsAsync(expextedTeam); //Act var result = await _teamController.GetAsync(teamId) as BadRequestObjectResult; //Assert Mapper.Reset(); Assert.Equal(400, result.StatusCode); }
public void GetTeamListAdvancedSearch_Success_Test() { // Arrange int? nucleoId = null; string name = null; string description = null; bool? active = null; //int pageIndex = 0; int pageSize = 10; // list IList <R_Team> list = new List <R_Team>(); for (int i = 1; i <= pageSize; i++) { list.Add(SampleTeam(i)); } // create mock for repository var mock = new Mock <ITeamRepository>(); mock.Setup(s => s.GetTeamListAdvancedSearch( Moq.It.IsAny <int?>() // nucleoId , Moq.It.IsAny <string>() // name , Moq.It.IsAny <string>() // description , Moq.It.IsAny <bool?>() // active )).Returns(list); // service TeamService teamService = new TeamService(); TeamService.Repository = mock.Object; // Act var resultList = teamService.GetTeamListAdvancedSearch( nucleoId , name , description , active ); TeamDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.TeamId); }
public Task <TeamDTO> EndPartnershipWithOrganization(long teamId, CancellationTokenSource cancellationTokenSource) => Task <TeamDTO> .Run(async() => { if (!CrossConnectivity.Current.IsConnected) { throw new InvalidOperationException(AppConsts.ERROR_INTERNET_CONNECTION); } TeamDTO resultTeam = null; TeamEndsPartnershipWithOrganizationRequest teamEndsPartnershipWithOrganizationRequest = new TeamEndsPartnershipWithOrganizationRequest() { AccessToken = GlobalSettings.Instance.UserProfile.AccesToken, Url = string.Format(GlobalSettings.Instance.Endpoints.TeamEndPoints.TeamEndPartnershipWithOrganizationApiKey, teamId) }; try { TeamEndsPartnershipWithOrganizationResponse teamEndsPartnershipWithOrganizationResponse = await _requestProvider.PostAsync <TeamEndsPartnershipWithOrganizationRequest, TeamEndsPartnershipWithOrganizationResponse>(teamEndsPartnershipWithOrganizationRequest); if (teamEndsPartnershipWithOrganizationResponse == null) { throw new InvalidOperationException(TEAM_END_PARTNERSHIP_WITH_ORGANIZATION_COMMON_ERROR_MESSAGE); } if (teamEndsPartnershipWithOrganizationResponse.Errors != null || teamEndsPartnershipWithOrganizationResponse.OrgError != null || teamEndsPartnershipWithOrganizationResponse.ProfileError != null || teamEndsPartnershipWithOrganizationResponse.TeamError != null) { throw new InvalidOperationException(string.Format("{0} {1} {2} {3}", teamEndsPartnershipWithOrganizationResponse.Errors?.FirstOrDefault(), teamEndsPartnershipWithOrganizationResponse.OrgError?.FirstOrDefault(), teamEndsPartnershipWithOrganizationResponse.ProfileError?.FirstOrDefault(), teamEndsPartnershipWithOrganizationResponse.TeamError?.FirstOrDefault()).Trim()); } else { resultTeam = _teamFactory.BuildTeam(teamEndsPartnershipWithOrganizationResponse); } } catch (ServiceAuthenticationException exc) { _identityUtilService.RefreshToken(); throw exc; } catch (Exception exc) { Crashes.TrackError(exc); throw; } return(resultTeam); }, cancellationTokenSource.Token);
public IHttpActionResult GetScoreTableResult(int teamId) { scoretableview _scoreTableView = null; LeaguesApiController leagueApi = new LeaguesApiController(); int position = 0; team _team = null; scoretableview[] _scoreTable = null; using (var context = new escorcenterdbEntities()) { _scoreTableView = (from s in context.scoretableviews where s.team == teamId select s).FirstOrDefault <scoretableview>(); _team = (from t in context.teams where t.Id == teamId && t.Enabled == true select t).FirstOrDefault <team>(); long seasonId = leagueApi.GetCurrentSeasonId(_team.League, DateTime.Now); _scoreTable = (from st in context.scoretableviews where st.season == seasonId select st).OrderBy(st => st.GamesWon.Value * 3 + st.GamesDrawn.Value * 1).ToArray <scoretableview>(); } if (_scoreTableView == null) { return(Ok()); } foreach (scoretableview st in _scoreTable) { if (st.team == teamId) { break; } position++; } // scoretableview y ScoreTableResultDTO son incompatibles team del primero es Int32, team del segundo es TeamDTO TeamDTO teamDTO = AutoMapper.Mapper.Map <team, TeamDTO>(_team); ScoreTableResultDTO scoreTableResultDTO = new ScoreTableResultDTO() { League = leagueApi.getLeagueNameById(_team.League), Position = (long)position, GamesDrawn = (long)_scoreTableView.GamesDrawn, GamesLost = (long)_scoreTableView.GamesLost, GamesPlayed = (long)_scoreTableView.GamesPlayed, GamesWined = (long)_scoreTableView.GamesWon, Points = (long)_scoreTableView.ScoreFavor, ScoreFavor = (long)_scoreTableView.ScoreFavor, ScoreDifference = (long)_scoreTableView.ScoreDifference, ScoreAgainst = (long)_scoreTableView.ScoreAgainst, Team = teamDTO }; return(Ok(scoreTableResultDTO)); }
public ActionResult Create(TeamViewModel team) { try { var teamDTO = new TeamDTO { Name = team.Name }; teamService.Create(teamDTO); return(Content("<h2>Команда создана</h2>")); } catch (ValidationException ex) { ModelState.AddModelError(ex.Property, ex.Message); } return(View(team)); }
public void searchByTeam(TeamDTO team) { Contests = stub.getListOfContestsByTeam(team.UID); }
public static TeamDTO registerTeam(string teamCode, string name, string registrationType) { ConvictsContext db = new ConvictsContext(); Team team = new Team(); string returnStatus = "false"; string errorMessage = ""; try { Team found = db.Teams.Find(teamCode); if (found == null) { team.TeamCode = teamCode; team.TeamName = name; team.TeamType = registrationType; team.ModifiedDate = DateTime.Now; team.Total = "0"; team.CreateDate = DateTime.Now; db.Teams.Add(team); db.SaveChanges(); } else { team = found; team.ModifiedDate = DateTime.Now; db.Entry(found).CurrentValues.SetValues(team); db.SaveChanges(); } returnStatus = "true"; } catch (Exception ex) { returnStatus = "false"; errorMessage = ex.Message; } TeamDTO returnobj = new TeamDTO(); returnobj.status = returnStatus; returnobj.errorMessage = errorMessage; returnobj.team = team ; return returnobj; }