public static List <Swap> UserSwaps(User user) { SwapRepository swapRepository = new SwapRepository(); List <Swap> swaps = swapRepository.Swaps; List <Swap> userSwap = new List <Swap>(); int daysInWeek = 7; foreach (var item in swaps) { int ItemDayToView = DateTime.Now.DayOfYear - item.When; if (item.From.Id != user.Id && item.Room.Id == user.Room.Id && ItemDayToView < daysInWeek) { item.DateOfReceiving = ActualSchedule.TransformToDateTime(item.When); userSwap.Add(item); } } return(userSwap); }
public static List <WhoWhenClean> GetActualSchedule(int countUsers, List <User> usersInRoom) { SwapRepository swapRepository = new SwapRepository(); List <Swap> swaps = swapRepository.Swaps; int today = DateTime.Now.DayOfYear; List <WhoWhenClean> initialSchedule = Algoritm.WhoWillCleanToday(countUsers); foreach (var item in swaps) { if (item.When < today && item.Agree == null) { initialSchedule = SwapLogics.ChangeDays(initialSchedule, item.When); } if (item.When > today && item.Agree != null) { initialSchedule = SwapLogics.ChangeUsers(initialSchedule, item.From, item.Agree, usersInRoom); } } return(initialSchedule); }