Ejemplo n.º 1
0
		public RegistrateInvoiceView(RegistrateInvoiceViewModel viewModel)
		{
			InitializeComponent();

			_viewModel = viewModel;
			DataContext = _viewModel;
			_viewModel.InvoiceSaved += _viewModel_InvoiceSaved;
			datagridComboBoxFöretag.ItemsSource = _viewModel.Companies;
			datagridComboBoxKostnadPo.ItemsSource = _viewModel.AllPeople;
		}
Ejemplo n.º 2
0
        public MainViewModel()
        {
            var personData  = new PersonDataAccess(RepositoryFactory <Person> .GetRepository());
            var companyData = new CompanyDataAccess(RepositoryFactory <Company> .GetRepository());
            var invoiceData = new InvoiceDataAccess(RepositoryFactory <Invoice> .GetRepository(), RepositoryFactory <InvoiceRow> .GetRepository());
            var userData    = new UserDataAccess(RepositoryFactory <User> .GetRepository());

            RegistratePersonViewModel  = new RegistratePersonViewModel(personData);
            RegistrateCompanyViewModel = new RegistrateCompanyViewModel(companyData);
            RegisterInvoiceViewModel   = new RegistrateInvoiceViewModel(invoiceData, companyData, personData);
            InvoiceViewModel           = new InvoiceViewModel(invoiceData);


            userData.AddUser("admin", "admin");
            LoginViewModel = new LoginViewModel(userData);
        }
Ejemplo n.º 3
0
		public MainViewModel()
		{
			var personData = new PersonDataAccess(RepositoryFactory<Person>.GetRepository());
			var companyData = new CompanyDataAccess(RepositoryFactory<Company>.GetRepository());
			var invoiceData = new InvoiceDataAccess(RepositoryFactory<Invoice>.GetRepository(), RepositoryFactory<InvoiceRow>.GetRepository());
			var userData = new UserDataAccess(RepositoryFactory<User>.GetRepository());

			RegistratePersonViewModel = new RegistratePersonViewModel(personData);
			RegistrateCompanyViewModel = new RegistrateCompanyViewModel(companyData);
			RegisterInvoiceViewModel = new RegistrateInvoiceViewModel(invoiceData, companyData, personData);
			InvoiceViewModel = new InvoiceViewModel(invoiceData);


			userData.AddUser("admin", "admin");
			LoginViewModel = new LoginViewModel(userData);
		}
Ejemplo n.º 4
0
		public void SaveTest()
		{
			var invoiceToSave = InvoiceHelper.CreateInvoices(1, 1)[0];

			var personDataAccessMock = new Mock<IPersonDataAccess>();
			var companyDataAccessMock = new Mock<ICompanyDataAccess>();
			var invoiceDataAccessMock = new Mock<IInvoiceDataAccess>();

			invoiceDataAccessMock.Setup(iA => iA.LoadInvoice(invoiceToSave.Id)).Returns(invoiceToSave);
			companyDataAccessMock.Setup(cA => cA.LoadAllCompanies()).Returns(new List<Company>());
			personDataAccessMock.Setup(pA => pA.LoadAllPeople()).Returns(new List<Person>());

			var viewModel = new RegistrateInvoiceViewModel(invoiceDataAccessMock.Object, companyDataAccessMock.Object, personDataAccessMock.Object) {InvoiceName = invoiceToSave.InvoiceName};
			viewModel.Invoices.AddRange(invoiceToSave.InvoiceRows);
			viewModel.Save();

			var loadedInvoice = invoiceDataAccessMock.Object.LoadInvoice(invoiceToSave.Id);
			
			InvoiceHelper.ValidateInvoice(invoiceToSave, loadedInvoice);
		}