Example #1
0
        public HttpResponseMessage AddAwardPromotion(PromotionAwardInputDTO promotion)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Claims claims = new Claims().Values();

                    AddAwardPromotionCommand command = new AddAwardPromotionCommand();
                    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 = (short)promotion.RequiredTimeForActivation;
                    command.PriceInHeeelps            = promotion.PriceInHeeelps;
                    command.NumberOfAvailableCoupons  = promotion.NumberOfAvailableCoupons;
                    command.NeighbourhoodId           = promotion.NeighbourhoodId;
                    command.UserSessionId             = promotion.UserSessionId;
                    command.ShortDescription          = promotion.ShortDescription;
                    command.UserSystemId              = promotion.UserSystemId;
                    bus.Send(command);
                }
                catch (Exception ex)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Example #2
0
        public void Handle(AddAwardPromotionCommand command)
        {
            PromotionAwardInputDTO promotion = new PromotionAwardInputDTO()
            {
                ExpertiseId               = command.ExpertiseId,
                NeighbourhoodId           = command.NeighbourhoodId,
                NumberOfAvailableCoupons  = command.NumberOfAvailableCoupons,
                PersonIntegrationCode     = command.PersonIntegrationCode,
                PromotionIntegrationCode  = command.PromotionIntegrationCode,
                PriceInHeeelps            = command.PriceInHeeelps,
                RequiredTimeForActivation = command.RequiredTimeForActivation,
                ShortDescription          = command.ShortDescription,
                StartDateUTC              = command.StartDateUTC,
                Title         = command.Title,
                UserSessionId = command.UserSessionId,
                UserSystemId  = command.UserSystemId,
                ValidUntilUTC = command.ValidUntilUTC
            };

            var _clientPromotion = new HttpClient();

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

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