Exemplo n.º 1
0
        private void AddReportBtn_Click(object sender, RoutedEventArgs e)
        {
            InitDataSource(ref reportItems, Mapper.ReportsToReportViewModels, reportController.Get);

            AddReport addReport = new AddReport(libraryItems);

            if (addReport.ShowDialog().Value)
            {
                LibraryViewModel model = addReport.SelectedItem;

                if (model != null)
                {
                    Library library = libraryController.GetById(model.Id);
                    Report  report  = new Report(library);
                    report.CountClients       = clientController.CountByLibraryId(library.Id);
                    report.CountSections      = sectionController.CountByLibraryId(library.Id);
                    report.CountBooks         = bookController.CountByLibraryId(library.Id);
                    report.CountBooksInUse    = bookClientController.CountInUseByLibraryId(library.Id);
                    report.CountBooksNotInUse = report.CountBooks - report.CountBooksInUse;

                    reportController.Add(report);
                    reportItems.Add(Mapper.ReportToReportViewModel(report));
                    return;
                }
            }
        }