package studycave.studycaverestservice.model.userActivity;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import studycave.studycaverestservice.model.flashcardset.Set;
import studycave.studycaverestservice.model.material.Material;
import studycave.studycaverestservice.model.studyGroup.GroupRepository;
import studycave.studycaverestservice.model.studyGroup.StudyGroup;
import studycave.studycaverestservice.model.test.Test;
import studycave.studycaverestservice.model.user.User;
import studycave.studycaverestservice.model.user.UserRepository;

@Service
public class UserActivityService {

    @Autowired
    UserRepository userRepository;
    @Autowired
    GroupRepository groupRepository;
    @Autowired
    UserActivityRepository userActivityRepository;

    public ResponseEntity<?> saveActivity(
            String type,
            int points,
            String comment,
            User toUser,
            User fromUser,
            StudyGroup group,
            Material material,
            Set set,
            Test test
    ) {
        UserActivity activity = new UserActivity();
        activity.setType(type);
        activity.setPoints(points);
        activity.setComment(comment);
        activity.setDate();
        activity.setToUser(toUser);
        activity.setFromUser(fromUser);
        activity.setGroup(group);
        activity.setTest(test);
        activity.setSet(set);
        activity.setMaterial(material);
        this.userActivityRepository.save(activity);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
