Beispiel #1
0
        /// <summary>
        /// Handles Change Organization Name Command
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <int> Handle(ChangeOrganizationNameCommand request, CancellationToken cancellationToken)
        {
            var currentOrg = _organizationRepository.FindById(request.Id, cancellationToken).Result;

            currentOrg.ChangeName(request.Name, request.ShortName);
            _organizationRepository.ChangeName(currentOrg);

            try
            {
                var result = await _organizationRepository
                             .UnitOfWork
                             .SaveChangesAsync(request.ChangedBy);

                await _mediator.Publish(new OrganizationNameChangeDomainEvent(currentOrg));

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }