public async Task <Joke> Add(Joke newJoke) { _context.Add(newJoke); var isSaved = await ProcessSave(); if (isSaved) { newJoke = _context.Jokes.Include(x => x.Joker).FirstOrDefault(x => x.Id == newJoke.Id); } return(newJoke); }
public async Task <User> Register(User newUser, string password) { var userUsername = newUser.Username.ToString().ToLower(); if (await isExistUser(userUsername)) { return(null); } byte[] passwordSalt, passwordHash; EncryptPassword(password, out passwordSalt, out passwordHash); newUser.PasswordSalt = passwordSalt; newUser.PasswordHash = passwordHash; newUser.Username = userUsername; newUser.isWithBadge = false; _context.Add(newUser); await _context.SaveChangesAsync(); return(newUser); }