/// <summary> /// Afhankelijk van het aantal gereden kilometers en de kilometers tot de volgende inspectie wordt een gepast DataTemplate meegegeven. /// Het inspectie gridview gebruikt dit om te bepalen wat de layout van elke inspectie moet zijn. Dit geeft aan hoe belangrijk of dichtbij een inspectie is. /// </summary> /// <param name="item">Inspectie object</param> /// <param name="container"></param> /// <returns>DataTemplate</returns> protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) { Inspectie inspectie = item as Inspectie; int kilometersGereden = GpsSupport.gpsSupport.GetKilometersGereden(); if (kilometersGereden < inspectie.Kilometerstand) { int tolerantieAankomend = GpsSupport.gpsSupport.GetTolerantieAankomend() + 1; int tolerantieDringend = GpsSupport.gpsSupport.GetTolerantieDringend() + 1; if (kilometersGereden > inspectie.Kilometerstand - tolerantieDringend) { return(this.DringendInspectieTemplate); } else if (kilometersGereden > inspectie.Kilometerstand - tolerantieAankomend) { return(this.BelangrijkInspectieTemplate); } else { return(this.StandaardInspectieTemplate); } } else if (inspectie.Status) { return(this.VoltooideInspectieTemplate); } else { return(this.OnvoltooideInspectieTemplate); } }
public void NotifyInspectieEdited(Inspectie i) { InspectionList.Remove(InspectionList.FirstOrDefault(inspectie => inspectie.Id == i.Id)); InspectionList.Add(new InspectieVM(i)); _editWindow.Close(); _editWindow = null; }
/// <summary> /// In deze methode zal zodra de pagina geladen is, de lijst met inspecties als ItemSource voor het grid instellen. /// Inspecties die eerder afgerond werden worden aan de SelectedItems van het grid toegevoegd zodat deze worden aangevinkt. /// Tenslotte wordt de eerste inspectie in de lijst die niet aangevinkt werd in beeld gescrolled. Indien een dringend (volgens de gps) eerst komt wordt deze in beeld gebracht. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void VerschillendeTestenPage_Loaded(object sender, RoutedEventArgs e) { gvwInspecties.HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; gvwInspecties.ItemsSource = inspecties; bool gescrolled = false; //Houd bij of naar het eerste onvoldooide activiteit gescrolled werd of niet. foreach (Inspectie inspectie in inspecties) { if (inspectie.Status) { gvwInspecties.SelectedItems.Add(inspectie); } else if (!gescrolled) { gescrolled = true; scrollenNaarInspectie = inspectie; } } if (scrollenNaarInspectie != null) { gvwInspecties.ScrollIntoView(scrollenNaarInspectie, ScrollIntoViewAlignment.Leading); } //scrollViewer van gridview ophalen is niet mogelijk in standaard RT - wel met WinRTXamlToolkit scrollViewer = gvwInspecties.GetFirstDescendantOfType <ScrollViewer>(); }
public InspectionVM(Inspectie inspectie) { _UOW = ViewModelLocator.UOW; _inspection = inspectie; _location = new LocationVM(_UOW.InspectionLocations.Get(Location_ID)); _customer = new CustomerVM(_UOW.Customers.Get(Customer_ID)); ChosenCertificates = new ObservableCollection <CertificateVM>(_UOW.Inspections.GetCertificatesByInspection(Inspection_ID).Select(cert => new CertificateVM(cert))); }
public static void RemoveInspectionByID(int id) { Inspectie inspection = new Inspectie() { Id = id }; RemoveInspection(inspection); }
public InspectionVM() { _inspection = new Inspectie(); _location = new LocationVM(); _customer = new CustomerVM(); ChosenCertificates = new ObservableCollection <CertificateVM>(); StartDate = DateTime.Now.Date; EndDate = DateTime.Now.Date.AddDays(1); }
public ActionResult <Bijenkast> PutBijenkast(int kastId, BijenkastDTO bijenkast) { Imker imker = _imkerRepository.GetBy(User.Identity.Name); if (imker == null) { return(Unauthorized()); } ; Bijenkast upTeDatenKast = _bijenkastRepository.GetBy(kastId); if (upTeDatenKast.imkerId != imker.ImkerId) { return(Unauthorized()); } upTeDatenKast.naam = bijenkast.naam; upTeDatenKast.type = bijenkast.type; upTeDatenKast.kleur = bijenkast.kleur; upTeDatenKast.aantalhoningkamers = bijenkast.aantalhoningkamers; upTeDatenKast.aantalbroedkamers = bijenkast.aantalbroedkamers; upTeDatenKast.aantalramenperkamer = bijenkast.aantalramenperkamer; upTeDatenKast.bijenras = bijenkast.bijenras; upTeDatenKast.moergeboortedag = bijenkast.moergeboortedag; upTeDatenKast.moergeboortejaar = bijenkast.moergeboortejaar; upTeDatenKast.moergeboortemaand = bijenkast.moergeboortemaand; upTeDatenKast.moergemerkt = bijenkast.moergemerkt; upTeDatenKast.moergeknipt = bijenkast.moergeknipt; upTeDatenKast.moerbevrucht = bijenkast.moerbevrucht; upTeDatenKast.aanmaakdag = bijenkast.aanmaakdag; upTeDatenKast.aanmaakmaand = bijenkast.aanmaakmaand; upTeDatenKast.aanmaakjaar = bijenkast.aanmaakjaar; upTeDatenKast.inspecties.Clear(); bijenkast.inspecties.ForEach(t => { Inspectie i = _inspectieRepository.GetBy(t.id); if (i == null) { _inspectieRepository.Add(t); _inspectieRepository.SaveChanges(); } else { _inspectieRepository.Update(t); _inspectieRepository.SaveChanges(); } }); upTeDatenKast.inspecties.Clear(); upTeDatenKast.inspecties = bijenkast.inspecties; _bijenkastRepository.Update(upTeDatenKast); _bijenkastRepository.SaveChanges(); return(upTeDatenKast); }
public static void RemoveInspection(Inspectie inspectie) { using (var context = new FestiSpecDBEntities()) { if (context.Inspectie.Find(inspectie.Id) == null) { return; } Inspectie inspectieToDelete = context.Inspectie.Find(inspectie.Id); context.Inspectie.Remove(inspectieToDelete); context.SaveChanges(); } }
public static void UpdateInspectie(Inspectie i) { using (var context = new FestiSpecDBEntities()) { var entity = context.Inspectie.Find(i.Id); entity.Naam = i.Naam; entity.Datum = i.Datum; entity.Wens = i.Wens; entity.Huisnummer = i.Huisnummer; entity.Postcode = i.Postcode; entity.StatusNaam = i.StatusNaam; entity.OfferteId = i.OfferteId; entity.KlantId = i.KlantId; context.SaveChanges(); } }
public static Inspectie AddInspection(Inspectie inspectie) { using (var context = new FestiSpecDBEntities()) { context.Gebruiker.Attach(inspectie.Gebruiker); foreach (Gebruiker g in inspectie.Gebruiker1) { context.Gebruiker.Attach(g); } context.Offerte.Attach(inspectie.Offerte); context.Klant.Attach(inspectie.Klant); context.Status.Attach(inspectie.Status); context.Inspectie.Add(inspectie); context.SaveChanges(); return(inspectie); } }
public static void AddIngevuldeVragenlijst(Inspectie inspectieModel, Gebruiker gebruiker, Vragenlijst vragenlijst, string data) { using (var context = new FestiSpecDBEntities()) { var insertable = new IngevuldeVragenlijst() { Gebruiker = gebruiker, IngevuldeVragenlijst1 = data, Vragenlijst = vragenlijst, Inspectie = inspectieModel }; context.Gebruiker.Attach(insertable.Gebruiker); context.Vragenlijst.Attach(insertable.Vragenlijst); context.Inspectie.Attach(inspectieModel); context.IngevuldeVragenlijst.Add(insertable); context.SaveChanges(); } }
/// <summary> /// Methode die luistert naar updates van de Geolocator. /// De ItemTemplateSelector wordt opnieuw aan het gridview toegewezen wat ervoor zorgt dat elk item opnieuw een DataTemplate /// toegewezen krijgt naargelang de gereden kilometers. /// </summary> /// <param name="kilometersGereden">kilometers is van het type int</param> private void LocatieUpdate(int kilometersGereden) { this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { foreach (Inspectie inspectie in inspecties) { if (kilometersGereden > inspectie.Kilometerstand - 501 && kilometersGereden < inspectie.Kilometerstand) { scrollenNaarInspectie = inspectie; break; } } DataTemplateSelector selector = gvwInspecties.ItemTemplateSelector; gvwInspecties.ItemTemplateSelector = null; gvwInspecties.ItemTemplateSelector = selector; gvwInspecties.ScrollIntoView(scrollenNaarInspectie); }).AsTask().Wait(); }
public async Task InitializeData() { _dbContext.Database.EnsureDeleted(); if (_dbContext.Database.EnsureCreated()) { Bijenkast b = new Bijenkast("Productievolk", "dadant", "#e9f900", 1, 1, 10, "buckfast", 5, 5, 2018, true, false, true, 6, 3, 2019, new List <Inspectie>()); Inspectie inspectie = new Inspectie(24, 4, 2019, "Dit is een eerste inspectie. Het bijenvolk ziet er goed uit!"); inspectie.eitjes = true; inspectie.larven = true; inspectie.poppen = true; inspectie.moeraanwezig = true; inspectie.ramenmetbijen = 6; _dbContext.Inspecties.Add(inspectie); b.inspecties.Add(inspectie); Imker imker = new Imker { email = "*****@*****.**", voornaam = "Lucas", achternaam = "Vermeulen", facebookimker = false }; await CreateUser(imker.email, "GelukkigGeenNetbeans123@!"); imker.bijenkasten.Add(b); _dbContext.Bijenkasten.Add(b); b = new Bijenkast("Aflegger", "simplex", "#7affef", 1, 0, 6, "buckfast", 20, 5, 2019, true, false, true, 3, 4, 2019, new List <Inspectie>()); inspectie = new Inspectie(24, 4, 2019, "Opletten! Het volk zou te weinig voer kunnen hebben!"); inspectie.eitjes = true; inspectie.larven = true; inspectie.poppen = false; inspectie.moeraanwezig = true; inspectie.ramenmetbijen = 2; _dbContext.Inspecties.Add(inspectie); b.inspecties.Add(inspectie); imker.bijenkasten.Add(b); _dbContext.Bijenkasten.Add(b); imker.bijenkasten.Add(b); _dbContext.Imkers.Add(imker); _dbContext.SaveChanges(); } }
/// <summary> /// Bij het klikken op een item in het grid wordt het item aangepast in de lijst met gewijzigde inspecties. /// Bovendien worden alle items in de geselecteerde items van het grid geüpdatet zodat deze aan- of afgevinkt worden. /// Er wordt bovendien terug naar de laatst geklikte positie gescrollen (geklikte grid tegen te linkerkant) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gvwInspecties_ItemClick(object sender, ItemClickEventArgs e) { Inspectie geklikteInspectie = (Inspectie)e.ClickedItem; int inspectieIndex = inspecties.IndexOf(geklikteInspectie); bool eerderGewijzigd = gewijzigdeInspecties.Contains(geklikteInspectie); if (eerderGewijzigd) { gewijzigdeInspecties.Remove(geklikteInspectie); } geklikteInspectie.Status = !geklikteInspectie.Status; inspecties.RemoveAt(inspectieIndex); inspecties.Insert(inspectieIndex, geklikteInspectie); gvwInspecties.ScrollIntoView(geklikteInspectie, ScrollIntoViewAlignment.Leading); try { gvwInspecties.SelectedItems.Clear(); foreach (Inspectie inspectie in inspecties) { if (inspectie.Status) { gvwInspecties.SelectedItems.Add(inspectie); } } } catch (COMException) { paLogging.log.Error(String.Format("Inspectie '{0}' kon niet aan- of afgevinkt worden.", geklikteInspectie.Activity)); } gvwInspecties.ScrollIntoView(geklikteInspectie, ScrollIntoViewAlignment.Leading); //terug scrollen naar huidige positie if (!eerderGewijzigd) { gewijzigdeInspecties.Add(geklikteInspectie); } }
private InspectieVM CreateTemplate() { //id of current user int GebruikerId = dataServer._gebruiker.Id; Klant klant = new Klant { Bedrijfsnaam = "Template bedrijf", Email = "*****@*****.**", Telefoonnummer = "0612345678", Postcode = "4581FJ", Huisnummer = 68 }; Offerte offerte = new Offerte { Prijs = 100.15, Toelichting = "Template offerte", Betaald = 0 }; Inspectie newInspectie = new Inspectie { RegistrantId = GebruikerId, Klant = klant, Status = new Status { Naam = "Geregistreerd" }, Offerte = offerte }; //does the offerte template already exist? int offertecount = dataServer.GetOfferte().Count(o => o.Toelichting.Equals("Template offerte")); //add offerte template to database if (offertecount == 0) { this.dataServer.AddOfferte(offerte); } //add template klant to database try { this.dataServer.AddKlant(klant); } catch (Exception e) { } //get id of TemplateKlant int templateKlantId = 0; var templateklant = dataServer.GetKlanten().Where(t => t.Bedrijfsnaam.Equals("Template bedrijf")); foreach (KlantVM t in templateklant) { templateKlantId = t.Id; } //get id of TemplateOfferte int templateOfferteId = 0; var templateOfferte = dataServer.GetOfferte().Where(o => o.Toelichting.Equals("Template offerte")); foreach (OfferteVM t in templateOfferte) { templateOfferteId = t.Id; } //set Id's for new inspectie newInspectie.Offerte.Id = templateOfferteId; newInspectie.OfferteId = templateOfferteId; newInspectie.Klant.Id = templateKlantId; newInspectie.KlantId = templateKlantId; //new inspection with template values InspectieVM inspectie = new InspectieVM(newInspectie) { Id = 0, Postcode = "5302XC", Datum = new DateTime(2019, 1, 1), StatusNaam = "Geregistreerd", Huisnummer = 52, Wens = "Het inspecteren van het festival", Inspecteur = new GebruikerVM { Id = GebruikerId, Naam = "Template", Achternaam = "van Festispec", Wachtwoord = "Template", Postcode = "5308LJ", Telefoonnummer = "0645781296", Huisnummer = 61, GeboorteDatum = new DateTime(1996, 1, 1), Email = "*****@*****.**", }, InspectieDatum = new DateTime(2019, 2, 1), Naam = "Template Inspectie" }; //does the template already exist? int templatecount = dataServer.GetInspecties().Count(i => i.Naam.Equals("Template Inspectie")); //add template to database if (templatecount == 0) { this.dataServer.AddInspection(inspectie); } return(inspectie); }
public void Add(Inspectie inspectie) { _inspecties.Add(inspectie); }
public void Update(Inspectie inspectie) { _inspecties.Update(inspectie); }
public void Delete(Inspectie inspectie) { _inspecties.Remove(inspectie); }
public InspectieVM() { this.InspectieModel = new Inspectie(); }
public InspectieVM(Inspectie inspectie) { this.InspectieModel = inspectie; }