Exemple #1
0
        /// <summary>
        /// Add new password
        /// </summary>
        /// <param name="secrets">user's password</param>
        /// <returns>ok</returns>
        public async Task AddSecrets(Secrets secrets)
        {
            Secrets existed = Secrets.FirstOrDefault(x => x.Id == secrets.Id);

            if (existed == null)
            {
                var login = Logins.LastOrDefault(x => x.Id > 0);
                if (login != null)
                {
                    secrets.Id = login.Id;
                }

                secrets.Password = PasswordManager.HashPassword(secrets.Password);
                await Secrets.AddAsync(secrets);
                await SaveChangesAsync();
            }
        }