Beispiel #1
0
        public async Task <StudentDto> RegisterStudentAccount(StudentDto input)
        {
            var passwordHash = new PasswordHasher().HashPassword(input.Password);

            input.Password = passwordHash;
            var mapped = input.MapTo <Student>();
            await _repository.InsertOrUpdateAndGetIdAsync(mapped);

            return(mapped.MapTo <StudentDto>());
        }
Beispiel #2
0
        public async Task <int> CreateOrUpdate(StudentDto input)
        {
            var mapped = input.MapTo <Student>();

            if (input.Id != 0)
            {
                var existing = _repository.Get(input.Id);
                var pass     = existing.Password;
                var entity   = input.MapTo(existing);

                entity.Password = pass;

                await _repository.UpdateAsync(entity);

                return(entity.Id);
            }
            mapped.Password = new PasswordHasher().HashPassword(input.Password);
            await _repository.InsertOrUpdateAndGetIdAsync(mapped);

            return(mapped.Id);
        }