예제 #1
0
 public Task AddAppToUserAsync(TUser user, string appId)
 {
     if (IsUserRegisteredForApp(user, appId))
     {
         throw new ArgumentException(string.Format("App {0} already has been added to user {1}", appId, user.Id));
     }
     UserAppRepository.Insert(new IdentityUserApp {
         AppId = appId, UserId = user.Id
     });
     return(Task.FromResult(0));
 }
예제 #2
0
        private IEnumerable <IdentityUserApp> GetUserApps(TUser user)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            var apps = UserAppRepository.GetByWhere(new Dictionary <string, object> {
                { "UserId", user.Id }
            });

            return(apps);
        }
예제 #3
0
        private IEnumerable <IdentityUserApp> GetUserAppList(TUser user, string appId)
        {
            if (user == null)
            {
                return(new List <IdentityUserApp>());
            }
            var userList = UserAppRepository.GetByWhere(new Dictionary <string, object>
            {
                { "UserId", user.Id },
                { "AppId", appId }
            });

            return(userList);
        }
예제 #4
0
        public IActionResult Register(UserRegister userRegister)
        {
            if (userRegister is null || !ModelState.IsValid)
            {
                return(BadRequest());
            }


            int id = UserAppRepository.Insert(new UserApp()
            {
                Username  = userRegister.Username,
                Email     = userRegister.Email,
                Firstname = userRegister.Firstname,
                Lastname  = userRegister.Lastname,
                DateBirth = userRegister.DateBirth,
                Password  = userRegister.Password
            });

            return(Ok(id));
        }
예제 #5
0
 public UserController(UserAppRepository userAppRepository)
 {
     UserAppRepository = userAppRepository;
 }
예제 #6
0
 public AuthController(UserAppRepository userAppRepository, TokenManager tokenManager)
 {
     UserAppRepository = userAppRepository;
     TokenManager      = tokenManager;
 }