using Demo.Data.LocalData; using Demo.domain.Models; using System; using System.Collections.Generic; using System.Linq; namespace Demo.Domain.UseCase { public class UseCaseGeneratePresence { public List GenerateDailyPresence(int startLesson, int endLesson, int groupId, DateTime currentDate) { var users = LocalStaticData.users.Where(u => u.GroupID == groupId).ToList(); var presences = new List(); for (int lesson = startLesson; lesson <= endLesson; lesson++) { foreach (var user in users) { presences.Add(new Presence { User = new User { Guid = user.Guid, FIO = user.FIO, Group = new Group { Id = groupId, Name = LocalStaticData.groups.First(g => g.Id == groupId).Name } }, Date = DateOnly.FromDateTime(currentDate), LessonNumber = lesson, IsAttedance = true }); } } return presences; } public List GenerateWeeklyPresence(int startLesson, int endLesson, int groupId, DateTime startDate) { var presences = new List(); for (int i = 0; i < 7; i++) { DateTime currentDate = startDate.AddDays(i); var dailyPresences = GenerateDailyPresence(startLesson, endLesson, groupId, currentDate); presences.AddRange(dailyPresences); } return presences; } } }