package com.nisum.mytime.service.impl;

import java.util.Date;
import java.util.List;

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

import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.repository.EmployeeLocationDetailsRepo;
import com.nisum.mytime.service.IEmployeeLocationService;

@Service
public class EmployeeLocationService implements IEmployeeLocationService{

	 @Autowired
	    private EmployeeLocationDetailsRepo employeeLocationDetailsRepo;
	
	 @Override
	    public void saveEmployeeLocationDetails(Employee employee) {
	        EmployeeLocationDetails employeeLocationDetails = new EmployeeLocationDetails();
	        employeeLocationDetails.setActive(employee.getEmpStatus().equalsIgnoreCase("Active"));
	        employeeLocationDetails.setEmployeeId(employee.getEmployeeId());
	        employeeLocationDetails.setEmployeeName(employee.getEmployeeName());
	        employeeLocationDetails.setCreateDate(new Date());
	        employeeLocationDetails.setEndDate(new Date());
	        employeeLocationDetails.setUpdatedDate(new Date());
	        employeeLocationDetails.setStartDate(new Date());
	        employeeLocationDetails.setEmpLocation(employee.getEmpLocation());
	        employeeLocationDetailsRepo.save(employeeLocationDetails);
	    }
	
	
	  @Override
	    public List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId) {
	        return employeeLocationDetailsRepo.findByEmployeeId(empId);
	    }
	  
	
	
}
