private void StockGenerator() { int dayCount = 0; while (dayCount < 30) { int hourCount = 0; DateTimeOffset now = DateTimeOffset.Now.Date; while (hourCount < 24) { AvailableDateStock stock = new AvailableDateStock() { AvailableDate = now.AddDays(dayCount).AddHours(hourCount), Type = TimeStockType.Course }; foreach (MemberWorkTime teacher in Teachers) { MemberWorkTimeItem match = teacher.Times.Where(x => x.Weekday == stock.AvailableDate.DayOfWeek && x.Time.Hours == stock.AvailableDate.Hour).FirstOrDefault(); if (match != null) { stock.Members.Add(new AvailableDateStockMember() { AvailableDate = stock.AvailableDate, Type = TimeStockType.Course, MemberId = teacher.MemberId }); } } AvailableDateStock.Add(stock); hourCount++; } dayCount++; } }
private void _removeStock(MemberWorkTimeItem item) { AvailableDateStock stock = Model.AvailableDateStock.FirstOrDefault(x => x.AvailableDate.DayOfWeek == item.Weekday && x.AvailableDate.Hour == item.Time.Hours); if (stock != null) { AvailableDateStockMember member = stock.Members.FirstOrDefault(x => x.MemberId == item.MemberId); stock.Members.Remove(member); } }
private void _addStock(MemberWorkTimeItem item) { AvailableDateStock stock = Model.AvailableDateStock.FirstOrDefault(x => x.AvailableDate.DayOfWeek == item.Weekday && x.AvailableDate.Hour == item.Time.Hours); if (stock != null) { stock.Members.Add(new AvailableDateStockMember() { AvailableDate = stock.AvailableDate, Type = TimeStockType.Course, MemberId = item.MemberId }); } }