Ejemplo n.º 1
0
        public void EditTest()
        {
            Report v = new Report();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.Temperature = 36;
                context.Set <Report>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(ReportVM));

            ReportVM vm = rv.Model as ReportVM;

            v    = new Report();
            v.ID = vm.Entity.ID;

            v.Temperature = 44;
            vm.Entity     = v;
            vm.FC         = new Dictionary <string, object>();

            vm.FC.Add("Entity.Temperature", "");
            _controller.Edit(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <Report>().FirstOrDefault();

                Assert.AreEqual(data.Temperature, 44);
            }
        }
Ejemplo n.º 2
0
        private void EditReportBtn_Click(object sender, RoutedEventArgs e)
        {
            ReportViewModel reportVM = dataGrid.SelectedItem as ReportViewModel;

            AddReport editReport = new AddReport(libraryItems, libraryItems.First(i => i.Id == reportVM.LibraryId));

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

                if (reportVM != null && model != null)
                {
                    Report  report  = reportController.GetById(reportVM.Id);
                    Library library = libraryController.GetById(model.Id);
                    reportVM.LibraryId        = library.Id;
                    report.Library            = 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.Edit(report);
                }
            }
        }