public async Task <ActionResult <ApiResponse> > CancelBooking(int bookingId, [FromServices] IBittnService bittnService) { var response = await bittnService.CancelBooking(new CancelBookingRequest { BookingId = bookingId }); return(response.Deleted ? ApiResponseHelper.Ok("Booking deleted.", response) : ApiResponseHelper.Fail("No booking deleted.", response)); }
public void Fail_Should_Return_Correctly() { var message = "message"; var actual = ApiResponseHelper.Fail(message); actual.Should().BeOfType <ActionResult <ApiResponse> >(); actual.Result.Should().BeOfType <ObjectResult>(); actual.Result.As <ObjectResult>().StatusCode.Should().Be(StatusCodes.Status200OK); actual.Result.As <ObjectResult>().Value.Should().BeOfType <ApiResponse>(); actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Success.Should().Be(false); actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Message.Should().Be(message); actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Data.Should().BeNull(); }