Exemple #1
0
        public async Task <IActionResult> ApiRegister([FromBody] CaRegisterModel model)
        {
            var apiMsg = new ApiMessage();

            try
            {
                var resultTuple = await userAccountBusiness.RegisterUserNamePwd(model);

                if (resultTuple.Item1)
                {
                    var accessToken = Guid.NewGuid().ToString();
                    var redisDoc    = new RedisDocument <string>();
                    redisDoc.ExpireTime = DateTime.Now.AddDays(30);
                    redisDoc.SetTime    = DateTime.Now;
                    redisDoc.Value      = resultTuple.Item3;
                    redisDoc.Key        = accessToken;
                    await distributedCache.SetValue(redisDoc);

                    apiMsg.Data = accessToken;
                }
                else
                {
                    apiMsg.SetFault(resultTuple.Item2);
                }
            }
            catch (Exception exc)
            {
                apiMsg.SetFault(exc);
            }
            return(Json(apiMsg));
        }
        public async Task <IActionResult> AddOrUpdate([FromBody] CaRegisterModel model)
        {
            ViewData["DataType"] = typeof(UserAccountEntry);
            var resultTuple = await userAccountBusiness.RegisterUserNamePwd(model, UserAccountBusiness.AdminUserRoleKey);

            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public async Task <IActionResult> Register(CaRegisterModel registerModel)
        {
            var result = new ApiMessage();

            var registerResult = await userAccountBusiness.RegisterUserNamePwd(registerModel);

            result.Success = registerResult.Item1;
            result.Message = registerResult.Item2;

            return(Json(result));
        }