public override async Task <Unit> Handle(Command command, CancellationToken cancellationToken)
            {
                var availableBudgets = await BudgetCategoryRepository.ListAllAsync();

                int?budgetId = null;

                for (var index = 0; index < command.BudgetCategoryOrder.Count; index++)
                {
                    var budgetCategoryId     = command.BudgetCategoryOrder[index].BudgetCategoryId;
                    var budgetCategoryEntity = availableBudgets.FirstOrDefault(x => x.Id == budgetCategoryId);
                    if (budgetCategoryEntity == null)
                    {
                        throw new NotFoundException("Budget category was not found");
                    }

                    budgetId = budgetCategoryEntity.BudgetId;
                    budgetCategoryEntity.Order = index;
                    await BudgetCategoryRepository.UpdateAsync(budgetCategoryEntity);
                }

                await BudgetCategoryRepository.SaveChangesAsync(cancellationToken);

                if (budgetId != null)
                {
                    _ = _mediator.Publish(new Notification()
                    {
                        BudgetId = budgetId.Value
                    },
                                          cancellationToken);
                }

                return(Unit.Value);
            }
            public override async Task <BudgetCategoryDto> Handle(Command command, CancellationToken cancellationToken)
            {
                var isAccessible = await BudgetCategoryRepository.IsAccessibleToUser(command.BudgetCategoryId);

                var budgetCategoryEntity = await BudgetCategoryRepository.GetByIdAsync(command.BudgetCategoryId);

                budgetCategoryEntity.Name = command.Name;
                budgetCategoryEntity.Icon = command.Icon;

                for (int i = 0; i < command.AmountConfigs.Count - 1; i++)
                {
                    command.AmountConfigs[i].ValidTo = command.AmountConfigs[i + 1]
                                                       .ValidFrom
                                                       .AddDays(-1)
                                                       .FirstDayOfMonth();
                    command.AmountConfigs[i + 1].ValidTo = null;
                }

                var amountConfigs = command.AmountConfigs
                                    .Select(x => new BudgetCategoryBudgetedAmount()
                {
                    BudgetCategoryId = budgetCategoryEntity.Id,
                    MonthlyAmount    = x.MonthlyAmount,
                    ValidFrom        = x.ValidFrom,
                    ValidTo          = x.ValidTo
                })
                                    .ToList();

                budgetCategoryEntity.BudgetCategoryBudgetedAmounts = amountConfigs;

                if (!(isAccessible))
                {
                    throw new NotFoundException("Budget category was not found");
                }

                await BudgetCategoryRepository.UpdateAsync(budgetCategoryEntity);

                var addedRows = await BudgetCategoryRepository.SaveChangesAsync(cancellationToken);

                if (addedRows.IsNullOrDefault())
                {
                    throw new SaveFailureException(nameof(budgetCategoryEntity), budgetCategoryEntity);
                }

                var dto = Mapper.Map <BudgetCategoryDto>(budgetCategoryEntity);

                _ = _mediator.Publish(new Notification()
                {
                    BudgetId       = budgetCategoryEntity.BudgetId,
                    BudgetCategory = dto
                }, cancellationToken);

                return(dto);
            }