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; }
public async Task<int> CreateAsync(User user) { _context.Users.Add(user); await _context.SaveChangesAsync(); return user.Id; }
public async Task UpdateAsync(User user) { await _userCommand.UpdateAsync(user); }
public async Task<int> CreateAsync(User user) { return await _userCommand.CreateAsync(user); }
public async Task UpdateAsync(User user) { _context.Entry(user).State = EntityState.Modified; await _context.SaveChangesAsync(); }