private TestTransaction.Response TestTransactionHandler(TestTransaction command) { try { var command1 = new CreatePerson { Age = 11, Birthday = DateTimeOffset.Now, FirstName = "Hengdeyang", IsActive = true, LastName = "Oliv", Sex = 0 }; var command2 = new CreateTeam { }; platform.CallCommand <CreatePerson, CreatePerson.Response>(command1); platform.CallCommand <CreateTeam, CreateTeam.Response>(command2); } catch (Exception ex) { throw ex; } }
public void ExecuteMethodPassThrowAddMemberToListMethod() { var mockedDatabase = new Mock <IDatabase>(); var mockedFactory = new Mock <IWIMFactory>(); var sut = new CreateTeam(mockedFactory.Object, mockedDatabase.Object); var mockedTeam = new Mock <ITeam>(); var parameters = new List <string>() { "Team14" }; var fakeListTeams = new List <ITeam>(); mockedDatabase.Setup(x => x.ListAllTeams).Returns(fakeListTeams); mockedFactory.Setup(x => x.CreateTeam("Team14")).Returns(mockedTeam.Object); var expected = string.Format(GlobalConstants.MemberCreated, "Team14"); var mockedActivity = new Mock <IActivity>(); mockedFactory.Setup(x => x.CreateActivity(expected)); mockedTeam.Setup(x => x.AddTeamActivity(mockedActivity.Object)); sut.Execute(parameters); mockedDatabase.Verify(x => x.AddTeamToList(mockedTeam.Object), Times.Once); }
public void CreateTeamIntegritey(CreateTeam request, ValidationOutcome outcome) { if (request.Team == null) { outcome.AddError("Team", "Something really bad"); } }
public async Task <IActionResult> Create([FromBody] CreateTeam request) { if (string.IsNullOrWhiteSpace(request.Name)) { return(BadRequest("The name is empty.")); } if (_context.Teams.Any(a => a.Name.Equals(request.Name))) { return(BadRequest("Already exist a team with the same name.")); } var team = new Team() { Name = request.Name, Id = Guid.NewGuid(), }; _context.Teams.Add(team); var result = await _context.SaveChangesAsync(); if (result <= 0) { return(BadRequest("There was an error saving the Team.")); } return(Ok(team)); }
/// <inheritdoc /> public override void Decode(MinecraftStream stream) { TeamName = stream.ReadString(); PacketMode = (Mode)stream.ReadByte(); switch (PacketMode) { case Mode.CreateTeam: var a = new CreateTeam(); a.Read(stream); Payload = a; break; case Mode.RemoveTeam: break; case Mode.UpdateTeam: var upd = new UpdateTeam(); upd.Read(stream); Payload = upd; break; case Mode.AddPlayer: var add = new AddPlayers(); add.Read(stream); Payload = add; break; case Mode.RemovePlayer: var remove = new RemovePlayers(); remove.Read(stream); Payload = remove; break; } }
public TeamResult CreateTeam(CreateTeam request) { return(new TeamResult { Team = request.Team }); }
/// <summary> /// 界面显示之前调用 /// </summary> protected override void OnStart(INotification notification) { if (promptMediator == null) { promptMediator = Facade.RetrieveMediator("PromptMediator") as PromptMediator; } PromtInfo info = notification.Body as PromtInfo; copyTeam = info.copyTeam; createTeam = info.createTeam; confirm = info.confirm; panel.context.text = info.context; panel.title.text = info.title; if (info.promtType == PromtType.CreateTeam) { panel.normal.gameObject.SetActive(false); panel.createTeam.gameObject.SetActive(true); panel.cancelBtn.transform.localPosition = new Vector3(0, -149, 0); } else if (info.promtType == PromtType.Normal) { panel.normal.gameObject.SetActive(true); panel.createTeam.gameObject.SetActive(false); } }
public IActionResult CreateTeam(int id, int idCT = -1) { var data = new CreateTeam(); data.save = id; data.back = 0; data.competition = _context.Competitions.FirstOrDefault(a => a.CompetitionId == id); data.partisipants = new List <Partisipant>(); if (idCT == -1) { data.team = new Team(); data.team.IsDeleted = 1; data.team.Name = ""; data.team.Comment = ""; _context.Teams.Add(data.team); _context.SaveChanges(); } else { data.compteam = _context.CompetitionTeams.FirstOrDefault(a => a.CompetitionTeamId == idCT); data.partisipants = (from TP in _context.TeamPartisipants join CT in _context.CompetitionTeams on TP.TeamId equals CT.TeamId join P in _context.Partisipants on TP.PartisipantId equals P.ParticipantId where CT.CompetitionTeamId == data.compteam.CompetitionTeamId select P).ToList(); data.team = _context.Teams.FirstOrDefault(a => a.TeamId == data.compteam.TeamId); } return(View(data)); }
public void ExecuteMethodReturnsCorrectResultWithCorrectInput() { var mockedDatabase = new Mock <IDatabase>(); var mockedFactory = new Mock <IWIMFactory>(); var sut = new CreateTeam(mockedFactory.Object, mockedDatabase.Object); var mockedTeam = new Mock <ITeam>(); var parameters = new List <string>() { "Team14" }; var fakeListTeams = new List <ITeam>(); mockedDatabase.Setup(x => x.ListAllTeams).Returns(fakeListTeams); mockedFactory.Setup(x => x.CreateTeam("Team14")).Returns(mockedTeam.Object); mockedDatabase.Setup(x => x.AddTeamToList(mockedTeam.Object)); var expected = string.Format(GlobalConstants.TeamCreated, "Team14"); Assert.AreEqual(expected, sut.Execute(parameters)); }
public ActionResult CreatTeam([FromBody] CreateTeam createTeam, [FromRoute] int companyId) { companyService.ValidCompany(companyId); int id = service.CreateTeam(createTeam, companyId); return(Created($"api/teams/{id}", null)); }
public JsonResult CreateTeam(CreateTeam command) { command.TeamId = command.TeamId == Guid.Empty ? Guid.NewGuid() : command.TeamId; Domain.Dispatcher.SendCommand(command); return(Json(command)); }
public async Task CreateAsync(CreateTeam cmd) { var task = State.TeamDoesNotExists() switch { Results.Unit => PersistPublishAsync(new TeamCreated(cmd.Name, cmd.TeamId, cmd.TraceId, cmd.InvokerUserId)), Results x => PublishErrorAsync(new ErrorHasOccurred((int)x, x.ToString(), cmd.TraceId, cmd.InvokerUserId)) }; await task; }
public void CreateProject_Test() { var createTeam = new CreateTeam(); teamRepoMock.Setup(x => x.CreateTeam(It.IsAny <Team>())).Verifiable(); teamSearvice.CreateTeam(createTeam, 1); teamRepoMock.Verify(x => x.CreateTeam(It.IsAny <Team>()), Times.Once); }
public int CreateTeam(CreateTeam createTeam, int companyId) { Team team = mapper.Map <Team>(createTeam); team.CompanyId = companyId; teamRepository.CreateTeam(team); return(team.Id); }
private CreateTeam.Response CreateTeamHandler(CreateTeam command) { ITracer tracer = platform.Tracer; tracer.Write("Siemens-SimaticIT-Trace-Custom", Category.Informational, "Create Team Start..."); //platform.CallCommand() //platform.SendCommand() //platform.Principal.Identity.Name Dictionary <string, object> dict = new Dictionary <string, object>() { { "command", "log test" } }; platform.ApplicationLog(12101, dict); try { var entity = platform.Create <ITeam>(); entity.Name = command.Team.Name; entity.Description = command.Team.Description; entity.Number = command.Team.Number; entity.IsActive = command.IsActive; entity.IsLeader = command.IsLeader; PropertyValuesSpecification <ITeam> pv = new PropertyValuesSpecification <ITeam>(); pv.Add("Name", command.Team.Name); var existentity = platform.GetEntity(pv); if (existentity == null) { platform.Submit(entity); } else { return(new CreateTeam.Response { Error = new ExecutionError(-1010, string.Format("[{0}]已经存在,不允许创建", command.Team.Name)) }); } tracer.Write("Siemens-SimaticIT-Trace-Custom", Category.Informational, "Create Team End..."); return(new CreateTeam.Response { Id = entity.Id }); } catch (Exception ex) { return(new CreateTeam.Response { Error = new ExecutionError(-1010, string.Format("[{0}]创建发生异常,异常信息是:{1}", command.Team.Name, ex.Message)) }); } }
public IActionResult Create(Guid id, [FromBody] CreateTeam model) { if (model == null) { return(BadRequest()); } _bus.Send(new commands.CreateTeam(id, model.Name)); return(CreatedAtRoute(nameof(GetById), new { controller = nameof(Team), id = id }, model)); }
public TeamResult CreateTeam(CreateTeam request, IHandler composer) { var team = request.Team; composer.Publish(new TeamCreated()); return(new TeamResult { Team = team }); }
public async Task <IActionResult> Create([FromBody] CreateTeam data, [FromHeader] string CompanyId) { if (ModelState.IsValid) { data.CreatedBy = User.Claims.FirstOrDefault(s => s.Type == "userName").Value; data.CompanyId = CompanyId; var result = await _createTeamRequestClient.Request(data); return(Ok(result)); } return(BadRequest(ModelState)); }
public void UpdateTeam(CreateTeam updatedTeam, int Id) { Team team = teamRepository.GetTeamById(Id); if (team is null) { throw new NotFoundException($"There is no team with id: {Id}"); } team = mapper.Map(updatedTeam, team); teamRepository.UpdateTeam(team); }
public bool CreateTeam(CreateTeam model) { var entity = new Team() { TeamName = model.TeamName }; using (var ctx = new ApplicationDbContext()) { ctx.Teams.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(CreateTeam ct) { if (this.ModelState.IsValid) { TeamController tc = new TeamController(); tc.Post(ct); return(RedirectToAction("Index", "Home")); //LOOKUP: redirect to action (take to another page) } else { return(View(ct)); } }
public void UpdateProject_Test() { var createTeam = new CreateTeam(); var team = GetTeam(); teamRepoMock.Setup(x => x.UpdateTeam(It.IsAny <Team>())).Verifiable(); teamRepoMock.Setup(x => x.GetTeamById(team.Id)).Returns(team); teamSearvice.UpdateTeam(createTeam, team.Id); teamRepoMock.Verify(x => x.UpdateTeam(It.IsAny <Team>()), Times.Once); Assert.Throws <NotFoundException>(() => teamSearvice.UpdateTeam(createTeam, 0)); }
/// <summary> /// Creates a Team with specific information. /// </summary> public IHttpActionResult Post(CreateTeam team) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateTeamService(); if (!service.CreateTeam(team)) { return(InternalServerError()); } return(Ok()); }
public void ExecuteMethodThrowExeptionWhenInputParametersCountIsSmaller() { var mockedDatabase = new Mock <IDatabase>(); var mockedFactory = new Mock <IWIMFactory>(); var sut = new CreateTeam(mockedFactory.Object, mockedDatabase.Object); var parameters = new List <string>() { }; var ex = Assert.ThrowsException <ArgumentException>(() => sut.Execute(parameters)); Assert.AreEqual(GlobalConstants.ParametersCountInvalid, ex.Message); }
public async Task <Team> AddAsync(CreateTeam command) { if (await _context.Teams.ExistsInDatabaseAsync(command.Name)) { throw new CorruptedOperationException("Team already exists."); } var team = new Team(command.Name); await _context.Teams.AddAsync(team); await _context.SaveChangesAsync(); return(team); }
public ActionResult Index(Entry entry) { CreateTeam teamModels = new CreateTeam(); teamModels.entryId = entry.Id; teamModels.regattaId = entry.RegattaId; IQueryable <Team> teams; using (var context = new TeamContext()) { var service = new TeamService(context); teams = service.GetAllByEntryId(entry.Id); } teamModels.teams = teams; return(View(teamModels)); }
public IActionResult ShowTeamComp(int idCT) { var data = new CreateTeam(); data.back = 0; data.compteam = _context.CompetitionTeams.FirstOrDefault(a => a.CompetitionTeamId == idCT); data.partisipants = (from TP in _context.TeamPartisipants join CT in _context.CompetitionTeams on TP.TeamId equals CT.TeamId join P in _context.Partisipants on TP.PartisipantId equals P.ParticipantId where CT.CompetitionTeamId == data.compteam.CompetitionTeamId select P).ToList(); data.team = _context.Teams.FirstOrDefault(a => a.TeamId == data.compteam.TeamId); data.competition = _context.Competitions.FirstOrDefault(a => a.CompetitionId == data.compteam.CompetitionId); return(View(data)); }
public async Task Create_New_Team_And_Return_OK() { var team = new CreateTeam() { Name = "UP Langreo", }; var content = new StringContent(JsonConvert.SerializeObject(team), UTF8Encoding.UTF8, "application/json"); var response = await _fixture.Server.CreateClient() .PostAsync(Post.Team, content); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <Team>(json); Assert.Equal("UP Langreo", result.Name); }
private void button1_Click(object sender, EventArgs e) { if (employeeGrid.SelectedRows.Count == 1) { int selectedrowindex = employeeGrid.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = employeeGrid.Rows[selectedrowindex]; string ID_employee = Convert.ToString(selectedRow.Cells["ID_employee"].Value); string ID_position = Convert.ToString(selectedRow.Cells["ID_position"].Value); CreateTeam formTeam = new CreateTeam(ID_employee, ID_position); Form1 f = new Form1(); formTeam.ShowDialog(this); f.Close(); } }
public async Task Create_New_Team_And_Return_OK() { var team = new CreateTeam() { Name = "UP Langreo", }; var content = new StringContent(JsonConvert.SerializeObject(team), UTF8Encoding.UTF8, "application/json"); var response = await _fixture.Server.CreateClient().PostAsync(Post.Team, content); response.Should().NotBeNull(); response.StatusCode.Should().BeEquivalentTo(StatusCodes.Status200OK); var contentResponse = await response.Content.ReadAsStringAsync(); var teamResponse = JsonConvert.DeserializeObject <Team>(contentResponse); teamResponse.Should().NotBeNull(); teamResponse.Name.Should().Be("UP Langreo"); }
// Create Team public HttpResult Post(CreateTeam request) { var settings = _adminSvc.Get(new GetSettings()); if (settings.RegistrationOpen == false) throw new UnauthorizedAccessException("New team registration is currently closed."); var team = request.ConvertTo<Team>(); team.ValidationToken = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); // Testing return new HttpResult(Get(new GetTeam { Id = 1 })) { StatusCode = HttpStatusCode.Created, Headers = { {HttpHeaders.Location, new GetTeam {Id = team.Id}.ToGetUrl()} } }; using (IDbTransaction trans = Db.OpenTransaction()) { Db.Save(team, references: true); var teamates = new List<Teamate>(); request.PlayerIds.ForEach(id => { teamates.Add(new Teamate {PlayerId = id, TeamId = team.Id}); }); Db.InsertAll(teamates); trans.Commit(); } return new HttpResult(Get(new GetTeam {Id = team.Id})) { StatusCode = HttpStatusCode.Created, Headers = { {HttpHeaders.Location, new GetTeam {Id = team.Id}.ToGetUrl()} } }; }