コード例 #1
0
        public async Task ShouldReturnGenericCommandResultSucessTrueWhenGetPollByIdCommandIsValid()
        {
            PollHandler _handler = new PollHandler(new FakePollRepository(), _mockLogger.Object);
            var         result   = (GenericCommandResult)await _handler.Handle(_getPollByIdCommandValid);

            Assert.IsTrue(_getPollByIdCommandValid.Valid);
            Assert.AreEqual(true, result.Success);
        }
コード例 #2
0
        public async Task <ActionResult <GenericCommandResult> > Get(Guid id, [FromServices] PollHandler handler)
        {
            var ret = (GenericCommandResult)await handler.Handle(new UpdatePollByIdCommand(id));

            if (!ret.Success)
            {
                _logger.LogWarning("Get --> {Id}", id, ret);
                return(BadRequest(ret));
            }
            _logger.LogInformation("Get --> {Id}", id, ret);

            return(Ok(ret));
        }
コード例 #3
0
        public async Task <ActionResult <GenericCommandResult> > Post([FromBody] CreatePollCommand command, [FromServices] PollHandler handler)
        {
            //var user = User.Claims.FirstOrDefault(x=>x.Type == "user_id")?.Value;
            var ret = (GenericCommandResult)await handler.Handle(command);

            if (!ret.Success)
            {
                _logger.LogWarning("Post --> ", ret);
                return(BadRequest(ret));
            }
            _logger.LogInformation("Post --> ", ret);
            return(Ok(ret));
        }