Exemplo n.º 1
0
        public void CreateGrouponParticipation(GrouponParticipationDTO model)
        {
            var activity = _grouponActivityRepository.Get(model.GrouponActivityId);

            if (activity == null)
            {
                throw new Exception("活动内容异常,无法找到指定的活动记录.");
            }

            if (!activity.IsInProcess())
            {
                throw new Exception("活动不在进行中.");
            }

            var objToAdd = new Domains.Aggregates.GrouponParticipation
            {
                BuyCount          = model.BuyCount,
                GrouponActivityId = model.GrouponActivityId,
                OrderId           = model.OrderId,
                ParticipateTime   = DateTime.Now,
                UserId            = model.UserId
            };

            _grouponParticipationRepository.Add(objToAdd);

            _dbUnitOfWork.Commit();

            objToAdd.ConfirmParticipated();
            _eventBus.Commit();
            //using (ITransactionCoordinator coordinator = new TransactionCoordinator(_dbUnitOfWork, _eventBus))
            //{
            //    coordinator.Commit();
            //}
        }
Exemplo n.º 2
0
        public async Task AddGrouponParticipation(GrouponParticipationDTO model)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Add("gooiosapikey", "83e960bff18221e39916012cc8e9f609");
                    client.DefaultRequestHeaders.Add("userid", model.UserId);

                    var reqUrl  = $"http://activityservice.gooios.com/api/GrouponParticipation/v1";
                    var jsonObj = JsonConvert.SerializeObject(model);
                    var content = new StringContent(jsonObj, Encoding.UTF8, "application/json");

                    var res = await client.PostAsync(reqUrl, content);
                }
            }
            catch (Exception ex)
            {
                //TODO: add error handle logic
            }
        }
Exemplo n.º 3
0
 public void Post([FromBody] GrouponParticipationDTO model)
 {
     model.UserId = UserId;
     _grouponParticipationAppService.CreateGrouponParticipation(model);
 }