Пример #1
0
        public async Task <Administrator> AddAdministratorcAsync(Administrator admin, string firstName, string lastName, string email, string password)
        {
            if (GetAdministratorAsync(email, password) != null)
            {
                throw new ArgumentException("administator already exist");
            }
            if (!validator.ValidateEmail(email) || !validator.ValidatePasswordLength(password))
            {
                throw new ArgumentException();
            }
            var newAdmin = new Administrator()
            {
                Id        = Guid.NewGuid(),
                FirstName = firstName,
                LastName  = lastName,
                Email     = email,
                Password  = password
            };

            await administratorRepository.AddAdministratorAsync(admin, newAdmin);

            return(newAdmin);
        }