예제 #1
0
        protected void AuthUser()
        {
            var userName = HttpContext.Current.Request["userName"];
            var token    = HttpContext.Current.Request["token"];

            if (!_homeOwerUserManager.AuthUser(userName, token))
            {
                throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.UserAuthError);
            }
            else
            {
                User = _homeOwerUserManager.HomeOwerUserRepository.FirstOrDefault(u => u.UserName == userName);
            }
        }
예제 #2
0
        public async virtual Task <IHttpActionResult> RegisterUserToHomeOwer(string userName, string token)
        {
            var homeOwerUser = await _homeOwerUserManager.HomeOwerUserRepository.FirstOrDefaultAsync(h => h.UserName == userName);

            if (homeOwerUser == null)
            {
                homeOwerUser = new HomeOwerUser(userName, token);
                await _homeOwerUserManager.CreateAsync(homeOwerUser);
            }
            else
            {
                homeOwerUser.Token = token;
                await _homeOwerUserManager.UpdateAsync(homeOwerUser);
            }
            return(Ok());
        }