Exemplo n.º 1
0
        public async Task <Result <int> > Handle(UpdateBenefitCommand command, CancellationToken cancellationToken)
        {
            var item = await _repository.GetByIdAsync(command.Id);

            if (item == null)
            {
                return(Result <int> .Fail($"JobAge Not Found."));
            }
            else
            {
                item.Name        = command.Name ?? item.Name;
                item.Code        = command.Code ?? item.Code;
                item.Icon        = command.Icon ?? item.Icon;
                item.Description = command.Description ?? item.Description;
                await _repository.UpdateAsync(item);

                await _unitOfWork.Commit(cancellationToken);

                return(Result <int> .Success(item.Id));
            }
        }