Esempio n. 1
0
        public async Task<int> GetUserId()
        {
            if (_appCache.Contains(UserIdKey))
                return _appCache.Get<int>(UserIdKey);

            int userId;
            var user = await _userService.GetByUserNameAsync(UserName);

            if (user == null)
            {
                // No user exists so let's create one
                user = new User
                {
                    Name = UserName,
                    UserName = UserName
                };
                userId = await _userService.CreateAsync(user/*, _appConfigHelper.SystemUserId*/);
            }
            else
                userId = user.Id;

            _appCache.Add(UserIdKey, userId);

            return userId;
        }
Esempio n. 2
0
        public async Task<int> CreateAsync(User user)
        {
            _context.Users.Add(user);

            await _context.SaveChangesAsync();

            return user.Id;
        }
Esempio n. 3
0
 public async Task UpdateAsync(User user) 
 {
     await _userCommand.UpdateAsync(user);
 }
Esempio n. 4
0
 public async Task<int> CreateAsync(User user)
 {
     return await _userCommand.CreateAsync(user);
 }
Esempio n. 5
0
        public async Task UpdateAsync(User user)
        {
            _context.Entry(user).State = EntityState.Modified;

            await _context.SaveChangesAsync();
        }