コード例 #1
0
        public IActionResult Create([FromBody] CategoryCreateDto categoryCreateDto)
        {
            CategoryCreateCommand categoryCreateCommand = MapService.Map(categoryCreateDto);
            Result result = _messages.Dispatch(categoryCreateCommand);

            return(FromResult(result));
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] CategoryCreateCommand command)
        {
            var id = await _mediator.Send(command);

            return(await Get(id));
        }
コード例 #3
0
        public CreateResponse Post(CategoryCreateCommand command)
        {
            var category = new Category
            {
                Id = Guid.NewGuid(),
                Name = command.Name,
                Frequency = command.Frequency
            };

            repositoryUnitOfWork.Categories.Create(category);

            // create budget to category relationship
            repositoryUnitOfWork.Budgets.AddCategoryToBudget(category.Id, command.BudgetId);

            return new CreateResponse { Id = category.Id };
        }
コード例 #4
0
 public Task CreateCategory([FromBody] CategoryCreateCommand categoryCreateCommand, CancellationToken cancellationToken)
 {
     return(mediator.Send(categoryCreateCommand, cancellationToken));
 }