public async Task Expect_Create_WithAutoCert_Target() { var targetCreate = new Add.Command() { Target = new TargetDto() { AutoCert = true, CreateSelfSignedCertificate = false, Domain = "www.netsparker.com", OriginIpAddress = "6.6.6.6", Proto = Infrastructure.Entity.Protocol.Http, State = Infrastructure.Entity.TargetState.Created, UseHttps = true, WAFEnabled = true } }; var targetCreateResult = await SendAsync(targetCreate); Assert.NotNull(targetCreateResult); Assert.True(targetCreateResult.IsSucceeded); var detailResult = await SendAsync(new Details.Query(targetCreateResult.Result.Id)); Assert.NotNull(detailResult); Assert.True(detailResult.IsSucceeded); Assert.Equal("www.netsparker.com", detailResult.Result.Domain); }
public void AddNewGame() { var fixture = new Fixture(); fixture.Customize(new AutoMoqCustomization()); var newGame = new Game { Title = "DDD" }; //Arrange using (var context = new GameManagementContext(ContextOptions)) { fixture.Inject(context); var command = new Add.Command { Title = newGame.Title }; var handler = fixture.Create <Add.CommandHandler>(); //Act var response = handler.Handle(command, new System.Threading.CancellationToken()).Result; var game = context.Games.SingleOrDefaultAsync(g => g.Title == newGame.Title).Result; //Assert Assert.True(response.Success); Assert.NotNull(game); Assert.Equal(newGame.Title, game.Title); } }
public async Task <IActionResult> Add( //Receive file [FromForm] Add.Command command ) { return(HandleResult(await Mediator.Send(command))); }
public async Task <IActionResult> AddTicker(TickerModel ticker) { var cmd = new Add.Command { Ticker = ticker }; var cnt = await _mediator.Send(cmd); return(Ok(cnt)); }
public async Task <IActionResult> Add(Add.Command command) { var result = await _mediator.Send(command); if (!result) { return(this.CommandResultFailureJson(result)); } return(this.RedirectToActionJson(nameof(Index))); }
public async Task Add_Favorite_NotLogged_WithValidInput_ShouldReturn_RestException() { var mockedContext = new EletronicPartsCatalogContextMock().GetMockedContextWithData(); var mockedCurrentUserAcessor = new Mock <ICurrentUserAccessor>(); var sut = new Add.QueryHandler(mockedContext, mockedCurrentUserAcessor.Object); var message = new Add.Command("slug"); await Assert.ThrowsAsync <RestException>(() => sut.Handle(message, CancellationToken.None)); }
public async Task <IActionResult> Add(Add.Command request) { if (!ModelState.IsValid) { return(View(await _mediator.Send(new Add.Query()))); } await _mediator.Send(request); TempData["ToastrSuccess"] = "Successfully added new product category."; return(View()); }
public async Task <object> Add(Add.Command input) { input.WithUserId(User.Identifier()); var r = await _mediator.Send(input); if (r.Error != null) { return(this.Error(r.Error)); } return(r.Aggregate); }
public async Task <IActionResult> Add(Add.Command command) { if (!ModelState.IsValid) { return(this.RedirectToActionJson(nameof(Index))); } await _mediator.Send(command); TempData["ToastrSuccess"] = "Successfully added new category"; return(this.RedirectToActionJson(nameof(Index))); }
public async Task SendComment(Add.Command command) { var username = GetUsername(); // send the username to the command command.Username = username; var comment = await _mediator.Send(command); // sending message to all clients connected to this chathub //await Clients.All.SendAsync("RecieveComment", comment); // sending message to all clients connected to a group await Clients.Group(command.ActivityId.ToString()).SendAsync("RecieveComment", comment); }
public async Task <IActionResult> Add([FromBody] PersonBindingModel bindingModel) { var command = new Add.Command { FirstName = bindingModel.FirstName, LastName = bindingModel.LastName, Gender = bindingModel.Gender }; command.SetUserName(User.Identity.Name); var result = await _mediator.Send(command); // Will create a separate log file for the specific date and category, if you want to categorized the logs //Log.Information($"Add API endpoint was called from {this.GetType().Name} by {User.Identity.Name}" + ",{Name}", this.GetType().Name); Log.Information($"Add API endpoint was called from {this.GetType().Name} by {User.Identity.Name}" + " | {Name}", this.GetType().Name); return(Ok(result)); }
public void AddNewGame_WithPlatform() { var fixture = new Fixture(); fixture.Customize(new AutoMoqCustomization()); var newGameTitle = "DDD"; var newGamePlatform = (Platform)SeedPlatforms[0]; //Arrange using (var context = new GameManagementContext(ContextOptions)) { fixture.Inject(context); var command = new Add.Command { Title = newGameTitle, Platforms = new [] { newGamePlatform } }; var handler = fixture.Create <Add.CommandHandler>(); //Act var response = handler.Handle(command, new System.Threading.CancellationToken()).Result; var game = context.Games .Include(g => g.GamePlatforms) .ThenInclude(p => p.Platform) .SingleOrDefaultAsync(g => g.Title == newGameTitle).Result; //Assert Assert.True(response.Success); Assert.NotNull(game); Assert.Equal(newGameTitle, game.Title); Assert.Equal(newGamePlatform.Id, game.GamePlatforms.FirstOrDefault()?.Platform.Id); Assert.Equal(newGamePlatform.Name, game.GamePlatforms.FirstOrDefault()?.Platform.Name); } }
public async Task Test() { string id = Guid.NewGuid().ToString(); Create.Command command = new Create.Command { Id = id, Categories = new[] { "/songs/recurrent" }, Title = "Test audio" }; await Mediator().Send(command); Add.Command addMarker = new Add.Command { Id = id, Name = "marker 1", Offset = 123 }; await Mediator().Send(addMarker); Process.Features.Audio.Categories.Add.Command addCategory = new Process.Features.Audio.Categories.Add.Command { Id = id, Category = "/songs/a-list", }; await Mediator().Send(addCategory); Remove.Command removeCategory = new Remove.Command { Id = id, Category = "/songs/a-list", }; await Mediator().Send(removeCategory); }
public async Task Expect_Create_WithSelfCert_Target() { var targetCreate = new Add.Command() { Target = new TargetDto() { AutoCert = false, CreateSelfSignedCertificate = true, Domain = "www.testsparker.com", OriginIpAddress = "2.2.2.2", Proto = Infrastructure.Entity.Protocol.Https, State = Infrastructure.Entity.TargetState.Redirected, UseHttps = true, WAFEnabled = true } }; var targetCreateResult = await SendAsync(targetCreate); Assert.NotNull(targetCreateResult); Assert.True(targetCreateResult.IsSucceeded); }
public async Task <IActionResult> Add([FromForm] Add.Command command) // [FromForm] attribute will tell API where to find the file { // command will include the file return(HandleResult(await Mediator.Send(command))); }
public async Task <ActionResult <Photo> > Add([FromForm] Add.Command command) { return(await Mediator.Send(command)); }
public async Task <IActionResult> Post([FromForm] Add.Command request, CancellationToken cancellationToken) { PhotoDto result = await Mediator.Send(request, cancellationToken); return(Ok(result)); }
public async Task <ActionResult <Unit> > Add(Add.Command command) { return(await _mediator.Send(command)); }
public async Task <ReportImage> Add([FromForm] Add.Command command) { return(await Mediator.Send(command)); }
public async Task <IActionResult> Add([FromForm] Add.Command command) { var result = await Mediator.Send(command); return(HandleResult(result)); }
public async Task <IActionResult> Add([FromForm] Add.Command addPhotoCommand) { return(HandleResult(await Mediator.Send(addPhotoCommand))); }
public Task <long> Add([FromBody] Add.Command request, CancellationToken token) { return(_mediator.Send(request, token)); }
public async Task <IActionResult> Add([FromBody] Add.Command command) { await _mediator.Send(command); return(Ok()); }
public async Task <IActionResult> Add([FromForm] Add.Command command, Guid projectId) { return(HandleResult(await Mediator.Send(new Add.Command { ProjectId = projectId, File = command.File }))); }
public Task <long> Post([FromBody] Add.Command request) { return(_mediator.Send(request)); }
public async Task <ActionResult <Photo> > Add([FromForm] Add.Command command) // Adding [FromForm] because we are getting Error 415: Unsupported Media File { return(await Mediator.Send(command)); }
public async Task<IActionResult> Add([FromForm] Add.Command command) { return HandleResult(await Mediator.Send(command)); }
public async Task <ActionResult <Photo> > Add([FromForm] Add.Command command) // [FromForm] is hint for runtime where to look when searching for photo: it should lokk at form-data instead of body { return(await Mediator.Send(command)); }
public async Task <ActionResult <Photo> > Add([FromForm] Add.Command command) { //Console.WriteLine(command); return(await Mediator.Send(command)); }
public async Task <ActionResult <Photo> > Add([FromForm] Add.Command command, CancellationToken cancellationToken) { return(await Mediator.Send(command, cancellationToken)); }