public async Task <IActionResult> GetById(Guid id) { KindResponse result = await KindService.GetKindAsync(new GetKindRequest() { Id = id }); return(Ok(result)); }
private async Task <bool> KindExists(Guid id, CancellationToken cancelationToken) { if (string.IsNullOrEmpty(id.ToString())) { return(false); } KindResponse result = await _kindService.GetKindAsync(new GetKindRequest() { Id = id }); return(result != null); }
public async Task GetKind_should_return_kind_with_specified_id(string guid) { //Arrange KindService sut = new KindService(KindRepo, VideoRepo, Mapper); //Act KindResponse result = await sut.GetKindAsync(new GetKindRequest() { Id = new Guid(guid) }); //Assert result.KindId.Should().Be(new Guid(guid)); Assert.NotNull(result.Name); }
public async Task AddKind_should_return_the_expected_kind() { //Arrange AddKindRequest expectedKind = new AddKindRequest() { KindName = GenData.Create <string>() }; KindService sut = new KindService(KindRepo, VideoRepo, Mapper); //Act KindResponse result = await sut.AddKindAsync(expectedKind); //Assert //expectedKind.Should().BeEquivalentTo(result, o => // o.Excluding(x => x.KindId)); Assert.Equal(expectedKind.KindName, result.Name); }
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { if (!(context.ActionArguments["id"] is Guid id)) { context.Result = new BadRequestResult(); return; } KindResponse result = await KindService.GetKindAsync(new GetKindRequest { Id = id }); if (result == null) { context.Result = new NotFoundObjectResult(new JsonErrorPayload { DetailedMessage = $"Kind with id {id} not exist." }); return; } await next(); }
public async Task <IActionResult> Post(AddKindRequest request) { KindResponse result = await KindService.AddKindAsync(request); return(CreatedAtAction(nameof(GetById), new { id = result.KindId }, null)); }