Exemplo n.º 1
0
        public async Task <bool> NewUserAsync(AppUser appUser, DateTimeOffset?dateTime = null)
        {
            // 验证用户是否存在
            if (!await appUserService.ExistsAsync(appUser))
            {
                //获取序号Id
                long sequentialId = await numbersFactory.CreateUserSequentailId(appUser.AppId);

                if (sequentialId > 0 && await appUserService.AddUserAsync(appUser, sequentialId))
                {
                    // 获取记录时间
                    DateTimeOffset now = dateTime ?? DateTimeOffset.Now.ToChinaStandardTime();

                    // 按小时
                    await UpdateCounter(appUser.GetNewUserCountKey(), OneHour, now);

                    // 按天
                    await UpdateCounter(appUser.GetNewUserCountKey(), OneDay, now);

                    // 按天 + 渠道
                    await UpdateCounter(appUser.GetNewUserCountKeyByChannel(), OneDay, now);

                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
 public async Task AddAsync(AppUser user)
 {
     await _service.AddUserAsync(user);
 }
Exemplo n.º 3
0
        public async Task <ActionResult> AddAsync(AppUser user)
        {
            await _service.AddUserAsync(user);

            return(Created("", null));
        }