Example #1
0
    public void InsertCategoryCommand()
    {
        var command = new InsertCategoryCommand("Name");

        var response = _mediator.HandleAsync <InsertCategoryCommand, long>(command).Result;

        Assert.IsTrue(response.Succeeded && response.Data > 0);
    }
Example #2
0
    public void InsertCategoryCommandShouldValidationFail()
    {
        var command = new InsertCategoryCommand(string.Empty);

        var response = _mediator.HandleAsync <InsertCategoryCommand, long>(command).Result;

        Assert.IsTrue(response.Failed);
    }
Example #3
0
        public async Task <APIResult> Insert([FromBody] InsertCategoryCommand command)
        {
            var id = await mediator.Send(command);

            return(new APIResult()
            {
                Data = new { id = (id > 0) ? id : (int?)null },
                Result = (id > 0) ? 0 : -1,
            });
        }
 public async Task <IActionResult> Post(InsertCategoryCommand request)
 => Ok(await _mediator.Send(request));