package es.uv.garcosda.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import es.uv.garcosda.domain.MyUser;
import es.uv.garcosda.repositories.UserRepository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;


@Service
@Transactional
public class UserService {
	
	@Autowired UserRepository ur;
	
	public Flux<MyUser> findAll(){
		return this.ur.findAll();
	}
	
	public Mono<MyUser> findByUsername(String username){
		return this.ur.findByUsername(username);
	}
	
	public Mono<MyUser> findByUsernameAndPassword(String username, String password) {
		return this.ur.findByUsernameAndPassword(username, password);
	}
	
	public Mono<MyUser> createUser(MyUser user) {
		return this.ur.save(user);
	}
	
	public Mono<MyUser> insert(MyUser user){
		return this.ur.save(user);
	}
	
	public Mono<Void> deleteAll() {
		return this.ur.deleteAll();
	}
	
}
