public async Task <bool> RegisterUserAsync(Users user)
        {
            try
            {
                var newUser = user;
                //set password
                var    c    = new RNGCryptoServiceProvider();
                byte[] salt = new byte[128];
                byte[] passResult;
                c.GetBytes(salt);
                // Convert.ToBase64String(salt);
                using (var hash = new Rfc2898DeriveBytes(
                           user.Password,
                           salt,
                           2048,
                           HashAlgorithmName.SHA512))
                {
                    passResult = hash.GetBytes(64);
                }
                user.Password = string.Format("{0}:{1}:{2}", 2048, Convert.ToBase64String(passResult), Convert.ToBase64String(salt));



                await _db.Users.AddAsync(newUser);

                await _db.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #2
0
        public async Task <int> Add(Model.JobOffer job)
        {
            int res = 0;

            try
            {
                _db.JobOffer.Add(job);
                await _db.JobOffer.AddAsync(job);

                await _db.SaveChangesAsync();

                return(1);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }

            return(res);
        }