private async void Button_Click(object sender, RoutedEventArgs e)
        {
            //DR - The new salesbag to be added to the db
            DataAccess.Entities.SalesBag newbag = new DataAccess.Entities.SalesBag();
            newbag.Name        = this.bagName.Text;
            newbag.Active      = true;
            newbag.DateCreated = DateTime.Now;
            newbag.ID          = Guid.NewGuid();

            //DR - This is the means of querying the database with an interface
            //  Found the code here https://msdn.microsoft.com/en-us/library/bb341406(v=vs.110).aspx
            IEnumerable <DataAccess.Entities.Category> query =
                this.sourceGrid.SelectedItems.Cast <DataAccess.Entities.Category>().Select(x => x);

            //DR - For each category, create a relationship tieing the new bag to each selected category
            foreach (DataAccess.Entities.Category i in query)
            {
                //DR - This is breaking as a nullexception on my end.  It should just create the relationship.
                await _salesBagCategoryRepository.AddCategoryToSalesBag(i, newbag);
            }

            //DR - Save the new bag to the database
            //await _salesBagRepository.SaveAsync(newbag);

            //After bag is created and saved to db, navigate back to the salesbag page.
            this.Frame.Navigate(typeof(SalesBagsView));
        }
Esempio n. 2
0
        /********************************************************************
         * Note field is the meeting unique ID + ".txt"
         * Should display all artifacts from salesbag
         *********************************************************************/
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            launchmeet      = (DataAccess.Entities.Meeting)e.Parameter;
            launchmeet.Note = launchmeet.ID.ToString() + ".txt";
            try
            {
                DataAccess.Entities.SalesBag salesbagChosen = await _salesbagRepo.Get(launchmeet.SalesBag);

                List <DataAccess.Entities.Artifact> sa = await _asalesbagRepo.GetAllSalesBagArtifacts(salesbagChosen);

                ArtView.ItemsSource = sa;
            }
            catch (NullReferenceException) { }
        }