Example #1
0
        public HttpResponseMessage TransactCoupon(TransactCouponDto coupon)
        {
            //transformar esse processo em um comando para dar opcao de tolerancia a falha
            try
            {
                Claims claims = new Claims().Values();
                coupon.UserId = claims.userSystemId;
                coupon.PersonIntegrationCode = claims.personIntegrationCode;
                //todo: o valor da usersession deveria estar presente nas claims
                //coupon.UserSessionIssue =

                TransactCouponCommand command = new TransactCouponCommand()
                {
                    CouponIntegrationCode = coupon.CouponIntegrationCode,
                    UserSessionTrade      = coupon.UserSessionTrade,
                    PersonIntegrationCode = claims.personIntegrationCode,
                    UserId = claims.userSystemId,
                    QRCode = coupon.QRCode
                };
                this.bus.Send(command);
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, new { }));
        }
Example #2
0
        public void Handle(TransactCouponCommand command)
        {
            TransactCouponDto coupon = new TransactCouponDto()
            {
                CouponIntegrationCode = command.CouponIntegrationCode,
                UserSessionTrade      = command.UserSessionTrade,
                PersonIntegrationCode = command.PersonIntegrationCode,
                UserId = command.UserId,
                QRCode = command.QRCode
            };

            var _clientPromotion = new HttpClient();

            _clientPromotion.BaseAddress = new Uri(CustomConfiguration.WebApiPromotion);
            var resultTask = _clientPromotion.PostAsJsonAsync("api/Coupon/TransactCoupon", coupon).Result;

            if (!resultTask.IsSuccessStatusCode)
            {
                LogManager.Error("Failure activating/transcting a Coupon. Status: " + resultTask.StatusCode);
                throw new Exception("Failure activating/transcting a Coupon. Status: " + resultTask.StatusCode);
            }
        }