/// <summary>
        /// This method is connected to the Delete Sculpture button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void Click_OnClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            await SculptureHandler.DeleteSculpture(ViewModel.PassedSculpture.ID);

            InspectionCatalogSingleton.Instance.Inspections = await new Persistancy.PersistenceFacade().GetAllInspections();
            SculptureCatalogSingleton.Instance.Sculptures.Remove(ViewModel.PassedSculpture);
            GoBack();
        }
        /// <summary>
        /// In the constructor we need to instantiate some of the fields and properties.
        /// </summary>
        public SelectedSculptureViewModel()
        {
            // Creates an instance of InspectionCatalogSingleton
            InspectionCatalogSingleton = InspectionCatalogSingleton.Instance;

            // Creates an instance of InspectionHandler
            InspectionHandler = new Handler.InspectionHandler(this);

            SculptureHandler = new SculptureHandler();

            // Creates an instance of NewInspection
            NewInspection = new Inspection();

            DeleteCommand = new RelayCommand(async() => await SculptureHandler.DeleteSculpture(PassedSculpture.ID));
        }
Пример #3
0
        /// <summary>
        /// This method is called when the user wants to create a new sculpture.
        /// We are gathering all the information from the ViewModel related to the new sculpture
        /// and we call the handler to proceed with the creation of the new sculpture.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AcceptButton_OnClick(object sender, RoutedEventArgs e)
        {
            ViewModel.NewSculpture.ID = SculptureCatalogSingleton.Instance.Sculptures.Last().ID + 1;
            SculptureHandler.CreateSculpture(ViewModel.NewSculpture);

            var parameterList = new List <int>();

            ViewModel.NewSculpture.SculptureMaterials.ForEach(material => parameterList.Add(material.ID));
            await new Persistancy.PersistenceFacade().UpdateSculptureMaterialsAsync(ViewModel.NewSculpture.ID, parameterList);

            var parameterList2 = new List <string>();

            ViewModel.NewSculpture.SculptureTypes.ForEach(type => parameterList2.Add(type));
            parameterList.Clear();
            parameterList2.ForEach(x =>
            {
                switch (x)
                {
                case "Skulptur":
                    parameterList.Add(1);
                    break;

                case "Sokkel":
                    parameterList.Add(2);
                    break;

                case "Relief":
                    parameterList.Add(3);
                    break;

                case "Vandkunst":
                    parameterList.Add(4);
                    break;

                default:
                    break;
                }
            });
            await new Persistancy.PersistenceFacade().UpdateSculptureTypesAsync(ViewModel.NewSculpture.ID, parameterList);
            Frame.Navigate(typeof(SculpturesView));
        }