async Task <Employee> IEmployeeManagementManager.CreateAsync(Employee employee)
 {
     employee.Validate();
     employee.Id       = Guid.NewGuid().ToString();
     employee.Password = "******";
     _cManager.AddToDatabase(employee.Id, employee);
     return(await _storage.SaveAsync(employee));
 }
コード例 #2
0
        public async Task <bool> ChangePasswordAysnc(string email, string oldPassword, string newPassword)
        {
            var employee = await _storage.GetByEmailAsync(email);

            if (employee == null)
            {
                throw new Exception("Invalid email.");
            }

            // update password
            if (oldPassword.Equals(employee.Password))
            {
                employee.Password = newPassword;
                await _storage.SaveAsync(employee);

                return(true);
            }
            else
            {
                return(false);
            }
        }