public async Task <UserDto> FindByGoogleId(string googleId) { var user = await _context.Users .FirstOrDefaultAsync(x => x.GoogleId == googleId); return(UserTranslator.ToModel(user)); }
/// <summary> /// Get single user /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <UserDto> Get(int id) { var dbUser = await _context.Users.Include(u => u.Office) .FirstOrDefaultAsync(x => x.Id == id); var user = UserTranslator.ToModel(dbUser); return(user); }
public async Task <UserDto> CreateFromGoogle(string googleId, UserDto user) { var dbUser = new User { GoogleId = googleId, Email = user.Email, Name = user.Name }; _context.Users.Add(dbUser); await _context.SaveChangesAsync(); return(UserTranslator.ToModel(dbUser)); }
public async Task <UserDto> Create(UserDto user, string password) { var dbUser = new User { Email = user.Email, Name = user.Name, Password = _passwordHasher.HashPassword(password) }; _context.Users.Add(dbUser); await _context.SaveChangesAsync(); return(UserTranslator.ToModel(dbUser)); }