Example #1
0
        public async Task <SuccessResponseVM> Handle(CreatePromo command, CancellationToken cancellationToken)
        {
            var result = new SuccessResponseVM();

            var request = command.Payload;
            var actor   = command.Actor.Name;

            using (var role = _promoRepository.CreateTransaction((int)IsolationLevel.Serializable))
            {
                try
                {
                    Promo data = request;
                    _promoRepository.SetActor(actor);

                    var roleCreated = await _promoRepository.CreateAsync(data);

                    result.IsSuccess = true;

                    await _promoRepository.CommitTransaction(role);
                }
                catch (Exception ex)
                {
                    await _promoRepository.RollbackTransaction(role);

                    throw ex;
                }
            }

            return(result);
        }