public void GridSum(List <Items> wrList) { DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); DateTime dt2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)); IEnumerable <ConcertEvent> concert = concertRepository.Get(p => p.EndDate <= dt2 && p.EndDate >= dt); //p.BeginningDate //(p => dt2 >= p.EndDate) for (int row = 0; row < workerRepository.GetAllFromCache().Count(); row++) { int sum = 0; int wrId = wrList[row].wrk.ID; foreach (ConcertEvent cncrt in concert) { if (concertMarkRepository.IsExist(p => p.ConcertEventID == cncrt.ID && p.WorkerID == wrId)) { sum += concertMarkRepository.Get(p => p.ConcertEventID == cncrt.ID && p.WorkerID == wrId).First().NumOfMarks; } } sum += lessonMarkRepository.Get(p => p.WorkerID == wrId && p.IsVisited == true).Count(); DataGridRow r = lessonGrid.GetRow(row); TextBlock s = (TextBlock)lessonGrid.GetCell(r, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) + 1).Content; s.Text = sum.ToString(); } }
public InfoWorker(Worker worker) { int sum = 0; List <Items> items = new List <Items>(); InitializeComponent(); lessonRepository = new LessonEventRepository(new ApplicationContext()); workerRepository = new WorkerRepository(new ApplicationContext()); lessonMarkRepository = new LessonMarksRepository(new ApplicationContext()); concertRepository = new ConcertEventRepository(new ApplicationContext()); concertMarkRepository = new ConcertMarksRepository(new ApplicationContext()); foreach (ConcertEvent con in concertRepository.Get(p => p.EndDate.Value.Month == DateTime.Now.Month)) { if (concertMarkRepository.IsExist(p => p.ConcertEventID == con.ID && p.WorkerID == worker.ID)) { Items item = new Items() { concert = con, marks = concertMarkRepository.Get(p => p.ConcertEventID == con.ID && p.WorkerID == worker.ID).First().NumOfMarks }; sum += item.marks; items.Add(item); } } concertListView.ItemsSource = items; this.Namelabel.Content = worker.Name; this.Surnamelabel.Content = worker.Surname; int lessonVisited = 0; foreach (LessonEvent lesson in lessonRepository.Get(p => p.Date.Month == DateTime.Now.Month)) { if (lessonMarkRepository.IsExist(p => p.LessonEventID == lesson.ID && p.WorkerID == worker.ID && p.IsVisited == true)) { lessonVisited++; } } sum += lessonVisited; this.numOfMakrslabel.Content = sum.ToString(); this.lessonVisitedNumLabel.Content = lessonVisited.ToString(); }