コード例 #1
0
        public async Task <string> ClaimPromotionAsync(string promoId, string name, string email, string clientId)
        {
            Promotion     clientPromotion = null;
            IRestResponse response        = null;

            try
            {
                using (_DbContext)
                {
                    clientPromotion = _DbContext.Promotion
                                      .Where(c => c.Id == promoId).First();
                    response = await _PromoService.SendPromoEmail(email, name, clientPromotion.Code);

                    if (response.IsSuccessful)
                    {
                        ApplicationUser appUser = _DbContext.Users.Where(u => u.Id == clientId).First();
                        _PromoService.HandleCLaimedPromotion(clientPromotion, _DbContext, name, email, appUser);
                        return("SUCCESS");
                    }
                    else
                    {
                        return("ERROR");
                    }
                }
            }
            catch (Exception ex)
            {
                //todo log exception
                return("ERROR");
            }
        }