private void AddSportAndTeams() { sportsStorage.Add(sport); foreach (Team t in GetFakeTeams()) { teamsStorage.Add(t); } }
//post methods public async Task <ActionResult <TeamModel> > Post(TeamModel model) { try { var exisiting = await _repository.GetTeamAsync(model.Moniker); if (exisiting != null) { return(BadRequest("Moniker in use")); } var location = _linkGenerator.GetPathByAction("Get", "Teams", new { moniker = model.Moniker }); if (string.IsNullOrWhiteSpace(location)) { return(BadRequest("Could Not use the current Moniker")); } //create a new map var team = _mapper.Map <Team>(model); _repository.Add(team); if (await _repository.SaveChangesAsync()) { return(Created($"/api/teams/{team.Moniker}", _mapper.Map <TeamModel>(team))); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest()); }
public TeamViewModel Create(TeamViewModel vmTeam) { var team = vmTeam.ToDataModel(); team.AdditionalDetailsJson = AdditionalDetailsFactory.CreateFootbalTeamsLocalCreationDetails().ToJson(); if (vmTeam.ManagerId.HasValue) { var manager = _memberRepository.GetManager(vmTeam.ManagerId.Value); team.AddManager(manager); } foreach (var playerId in vmTeam.SelectedPlayerIds) { var player = _memberRepository.GetPlayerWithNoTeam(playerId); if (player != null) { team.AddPlayer(player); } } _teamRepository.Add(team); return(team.ToViewModel()); }
/// <summary> /// Create a new team. /// </summary> /// <param name="teamToCreate">A Team to create.</param> public void Create(Team teamToCreate) { _authService.CheckAccess(AuthOperations.Teams.Create); Player captain = GetPlayerById(teamToCreate.CaptainId); if (captain == null) { // ToDo: Revisit this case throw new MissingEntityException(ServiceResources.ExceptionMessages.PlayerNotFound, teamToCreate.CaptainId); } // Check if captain in teamToCreate is captain of another team if (captain.TeamId != null) { var existTeam = GetPlayerLedTeam(captain.Id); VerifyExistingTeamOrThrow(existTeam); } ValidateTeam(teamToCreate); _teamRepository.Add(teamToCreate); captain.TeamId = teamToCreate.Id; _playerRepository.Update(captain); _playerRepository.UnitOfWork.Commit(); }
public void TestAddTeam() { /* ================== Montando Cenario =================== */ ITeamRepository teamRepository = GetInMemoryTeamRepository(); var brasil = new Team("Brasil", "BRA"); /* ================== Execucao =================== */ var teamSaved = teamRepository.Add(brasil); /* ================== Verificacao =================== */ // Testando com Assert Assert.NotEmpty(teamRepository.GetAll().ToList()); //Assert.Equal(1, teamSaved.TeamId); Assert.Equal("Brasil", teamSaved.Name); Assert.Equal("BRA", teamSaved.Flag); // Testando com FluentAssertions //teamRepository.Should().NotBeNull(teamRepository.GetAll().ToList().Count.ToString(), // $"O objeto esperado não corresponde com ao objeto obtido" + // $" ({teamRepository.GetAll().ToList().Count.ToString()})"); //teamSaved.TeamId.Should().Be(1, // $"O Id do objeto esperado não corresponde com o Id do objeto obtido {teamSaved.TeamId}"); //teamSaved.Name.Should().Be("Brasil", // $"O nome do time esperado não corresponde com o nome obtido {teamSaved.Name}"); //teamSaved.Flag.Should().Be("BRA", // $"A bandeira não corresponde coma a obtida {teamSaved.Flag}"); }
public Team UpdateTeam(Team team) { return(ExecuteFaultHandledOperation(() => { var groupNames = new List <string>() { BudgetModuleDefinition.GROUP_ADMINISTRATOR, BudgetModuleDefinition.GROUP_BUSINESS }; AllowAccessToOperation(BudgetModuleDefinition.SOLUTION_NAME, groupNames); ITeamRepository teamRepository = _DataRepositoryFactory.GetDataRepository <ITeamRepository>(); Team updatedEntity = null; if (team.TeamId == 0) { updatedEntity = teamRepository.Add(team); } else { updatedEntity = teamRepository.Update(team); } return updatedEntity; })); }
/// <summary> /// Create a new team. /// </summary> /// <param name="teamToCreate">A Team to create.</param> public Team Create(CreateTeamDto teamToCreate) { _authService.CheckAccess(AuthOperations.Teams.Create); if (teamToCreate.Captain == null) { throw new EntityInvariantViolationException("Captain can not be null"); } ThrowExceptionIfTeamWithSuchNameExists(teamToCreate.Name); var captain = GetPlayerById(teamToCreate.Captain.Id); if (captain == null) { throw new MissingEntityException(ServiceResources.ExceptionMessages.PlayerNotFound, teamToCreate.Captain.Id); } // Check if captain in teamToCreate is captain of another team var existTeam = GetTeamLedByCaptain(captain.Id); VerifyExistingTeamOrThrow(existTeam); return(_teamRepository.Add(teamToCreate)); }
public async Task <string> Post([FromBody] Team Team) { Team.TeamId = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); await _teamRepository.Add(Team); return("true"); }
public IEnumerable <AppTeamSite> Update(IEnumerable <AppTeamSite> models) { // Need to deleted items\ var deleteItems = _teamRepository.GetAllTeams().Where(l => !models.Where(_ => _.Id.HasValue).Select(_ => _.Id).Contains(l.Id)); if (deleteItems != null && deleteItems.Count() > 0) { foreach (var team in deleteItems) { _teamRepository.Remove(team); } } // Add or modify foreach (var team in models) { if (team.Id.HasValue) { // update //_teamRepository.Modify(team.ToTeamSite()); } else { team.CreatedDate = DateTime.Now.ToShortDateString(); team.TeamGuid = Guid.NewGuid(); // Set owner list var teamOwnersStr = team.TeamOwners.Split(';'); TeamSite addedTeam = team.ToTeamSite(); addedTeam.TeamOwners = new List <User>(); foreach (var t in teamOwnersStr) { if (t.Trim() != "") { addedTeam.TeamOwners.Add(_userRepository.GetUserByName(t)); } } Domain.MainBoundedContext.Tiles.Aggregates.Tile tile = new Domain.MainBoundedContext.Tiles.Aggregates.Tile(); //INSERT INTO Tiles VALUES('All Reports','1',@TeamSiteID,2,null,4,0,0,1,1,'#6DC2E9','','','','Centered',0) tile.Title = "All Reports"; tile.IsCustomized = true; tile.TileType = 2; tile.LogicStringType = 4; tile.Top = 0; tile.Left = 0; tile.Width = 1; tile.Height = 1; tile.BackgroundColor = "#6DC2E9"; tile.ReportCountStyle = "Centered"; tile.LogicString = "AllReports"; addedTeam.Tiles.Add(tile); _teamRepository.Add(addedTeam); } } //Submit changes _teamRepository.UnitOfWork.Commit(); return(GetAllTeamSites()); }
public virtual IActionResult CreateTeam([FromBody] Team newTeam) { repository.Add(newTeam); //TODO: add test that asserts result is a 201 pointing to URL of the created team. //TODO: teams need IDs //TODO: return created at route to point to team details return(this.Created($"/teams/{newTeam.ID}", newTeam)); }
void ITeamService.Create(Team team) { _teamRepository.Add(team); if (this._log.IsInfoEnabled) { this._log.InfoFormat("新增团队#{0}|{1}", team.ID, team.Name); } }
public void Handle(CreateTeamCommand command) { EnsureArg.IsNotNull(command); var commmandEntity = Mapper.Map <Domain.Entities.Team>(command.TeamModel); teamRepository.Add(commmandEntity); teamRepository.SaveChanges(); }
public JsonResult AddTeam(string team) { teamRepository.Add(new Team { IsDelete = false, Name = team }); teamRepository.SaveChanges(); context.Clients.All.SendAsync("refreshOpts"); return(Json(team)); }
public IActionResult Create(Team team) { if (ModelState.IsValid) { Team newTeam = _teamRepository.Add(team); return(RedirectToAction("Index")); } return(View(team)); }
public void ModifyAddedTeams() { UserId userId1 = new UserId { Name = "name1", Surname = "surname1", UserName = "******", Password = "******", Email = "*****@*****.**" }; User user = factory.CreateAdmin(userId1); usersStorage.Add(user); Sport toPlay = new Sport("Soccer", true); Team fakeTeam = GetFakeTeam(toPlay); teamsStorage.Add(fakeTeam); user.AddFavourite(fakeTeam); usersStorage.Modify(user); User stored = usersStorage.Get(user.UserName); Assert.AreEqual(1, stored.GetFavouriteTeams().Count); }
public async Task <IActionResult> PostTeam([FromBody] Teams team) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _teamRepository.Add(team); return(Content("created_id")); }
public async Task <IActionResult> Add([FromBody] Team team) { try { return(this.Ok(await _repository.Add(team))); } catch (Exception e) { return(this.Ok(TranslateError.Convert(e))); } }
public async Task <IActionResult> AddTeam(Team team) { teamRepository.Add(team); if (await dataContext.Commit()) { return(CreatedAtRoute("GetTeam", new { id = team.Id }, team)); } return(BadRequest("Could not add team.")); }
public TeamResponse Create(TeamRequest request) { if (request == null) { throw new ArgumentNullException("entity"); } var response = _repository.Add(Mapper.Map <Team>(request)); _unitOfWork.Commit(); return(Mapper.Map <TeamResponse>(response)); }
public async Task <IActionResult> Create([Bind("Id,TeamType")] Team team) { if (ModelState.IsValid) { repository.Add(team); await repository.SaveAsync(); return(RedirectToAction(nameof(Index))); } return(View(team)); }
public async Task <IHttpActionResult> PostTeam(Team team) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await teamRepository.Add(team); return(CreatedAtRoute("DefaultApi", new { id = team.teamId }, team)); }
public async Task <ActionResult <bool> > create(Team teamToCreate) { var newteam = new Team() { Teamnumber = teamToCreate.Teamnumber, Description = teamToCreate.Description }; _teamRepo.Add(newteam); return(await _teamRepo.SaveAll()); }
public async Task <IActionResult> PostTeam([FromForm] Team team) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _repository.Add(team); await _unitOfWork.CompleteAsync(); return(Ok()); }
public Task Handle(DefineTeamCommand command) { if (!teamRepository.IsExist(command.Title)) { teamRepository.Add(new Team(command.TeamId, command.Title)); } else { throw new Exception("Team is already existed!!!"); } return(Task.CompletedTask); }
private void AddTeamsToRepo() { foreach (Team team in teamsCollection) { teamStorage.Add(team); } }
private void OnSave() { UpdateTeam(Team, _editingTeam); if (EditMode) { _repo.Update(_editingTeam); } else { _repo.Add(_editingTeam); } Done(); }
public async Task <bool> Handle(CreateTeamCommand request, CancellationToken cancellationToken) { _teamRepository.Add(new Domain.AggregatesModel.TeamAggregate.Team( request.Name, request.ManagerId, request.Alliance, request.Tribe, request.Email, Guid.NewGuid())); return(await _teamRepository.UnitOfWork .SaveEntitiesAsync(cancellationToken)); }
// POST api/team public HttpResponseMessage Post([FromBody] Team team) { team = TeamRepository.Add(team); TeamRepository.Save(); HttpResponseMessage response = Request.CreateResponse <Team>(HttpStatusCode.Created, team); string uri = Url.Link("DefaultApi", new { id = team.Id }); response.Headers.Location = new Uri(uri); return(response); }
public IActionResult Add(string teamName, string teamDescription, IFormFile logo) { var newTeam = new Team() { Name = teamName, Description = teamDescription, Logo = logo == null ? "default_logo.png" : UploadedImage(logo) }; _teamRepository.Add(newTeam); _teamRepository.Save(); return(RedirectToAction("Index")); }
public void AddTeam(Team t) { if (t == null) { throw new ArgumentException("Team is missing"); } if (repo.GetById(t.Id) != null) { throw new InvalidOperationException("Team already in Repository"); } ValidateTeam(t); repo.Add(t); }