using Demo.Data.Repository;
using Demo.Domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Demo.Domain.UseCase
{
    public class UseCasePresence
    {
        private readonly IPresenceRepository _presenceRepository;

        public UseCasePresence(IPresenceRepository presenceRepository)
        {
            _presenceRepository = presenceRepository;
        }

        public IPresenceRepository PresenceRepository => _presenceRepository;

        public IEnumerable<Presence> GetPresenceByGroup(int groupId)
        {
            return _presenceRepository.GetPresenceByGroup(groupId)
                .Select(p => new Presence
                {
                    Id = p.Id,
                    Date = p.Date,
                    LessonNumber = p.LessonNumber,
                    IsAttendance = p.IsAttendance,
                    UserId = p.UserId
                });
        }

        public IEnumerable<Presence> GetPresenceByGroupAndDate(int groupId, DateTime date)
        {
            return _presenceRepository.GetPresenceByGroupAndDate(groupId, date)
                .Select(p => new Presence
                {
                    Id = p.Id,
                    Date = p.Date,
                    LessonNumber = p.LessonNumber,
                    IsAttendance = p.IsAttendance,
                    UserId = p.UserId
                });
        }

        public void MarkUserAsAbsent(Guid userId, int lessonNumber, DateTime date)
        {
            _presenceRepository.MarkUserAsAbsent(userId, lessonNumber, date);
        }

        internal object GetPresenceByGroup(Guid userId)
        {
            throw new NotImplementedException();
        }
    }
}