Пример #1
0
        public HttpResponseMessage AddGiftPromotion(PromotionGiftInputDTO promotion)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    AddGiftPromotionCommand command = new AddGiftPromotionCommand();
                    command.PromotionIntegrationCode = promotion.PromotionIntegrationCode;
                    command.PersonIntegrationCode    = promotion.PersonIntegrationCode;
                    command.ExpertiseId               = promotion.ExpertiseId;
                    command.Title                     = promotion.Title;
                    command.ShortDescription          = promotion.ShortDescription;
                    command.StartDateUTC              = promotion.StartDateUTC;
                    command.ValidUntilUTC             = promotion.ValidUntilUTC;
                    command.RequiredTimeForActivation = promotion.RequiredTimeForActivation;
                    command.PromotionBillingModelId   = promotion.PromotionBillingModelId;
                    command.PromotionPaymentTypeId    = promotion.PromotionPaymentTypeId;
                    command.NumberOfAvailableCoupons  = promotion.NumberOfAvailableCoupons;
                    command.NeighbourhoodId           = promotion.NeighbourhoodId;
                    command.PotencialDemand           = promotion.PotencialDemand;
                    command.UserSession               = promotion.UserSession;
                    command.IssueDateUTC              = promotion.IssueDateUTC;
                    command.UserSystemId              = promotion.UserSystemId;

                    bus.Send(command);
                }
                catch (Exception ex)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #2
0
        public void Handle(AddGiftPromotionCommand command)
        {
            PromotionGiftInputDTO promotion = new PromotionGiftInputDTO()
            {
                ExpertiseId               = command.ExpertiseId,
                NeighbourhoodId           = command.NeighbourhoodId,
                NumberOfAvailableCoupons  = command.NumberOfAvailableCoupons,
                PersonIntegrationCode     = command.PersonIntegrationCode,
                PotencialDemand           = command.PotencialDemand,
                PromotionBillingModelId   = command.PromotionBillingModelId,
                PromotionIntegrationCode  = command.PromotionIntegrationCode,
                PromotionPaymentTypeId    = command.PromotionPaymentTypeId,
                RequiredTimeForActivation = command.RequiredTimeForActivation,
                ShortDescription          = command.ShortDescription,
                StartDateUTC              = command.StartDateUTC,
                Title         = command.Title,
                UserSession   = command.UserSession,
                UserSystemId  = command.UserSystemId,
                ValidUntilUTC = command.ValidUntilUTC
            };

            var _clientPromotion = new HttpClient();

            _clientPromotion.BaseAddress = new Uri(CustomConfiguration.WebApiPromotion);
            var resultTask = _clientPromotion.PostAsJsonAsync("api/Promotion/AddGiftPromotion", promotion).Result;

            if (!resultTask.IsSuccessStatusCode)
            {
                LogManager.Error("Failure creating a new Gift Promotion. Status: " + resultTask.StatusCode);
                throw new Exception("Failure creating a new Gift Promotion. Status: " + resultTask.StatusCode);
            }
        }