示例#1
0
        public void AddInspectie()
        {
            if (Valid())
            {
                Status statusTemp = new Status();
                statusTemp.Naam = SelectedStatus.Naam;
                List <Gebruiker> selectedGebruikers = new List <Gebruiker>();
                GebruikerList.Where(g => g.IsIncluded).ToList().ForEach(g => selectedGebruikers.Add(g.GebruikerModel));

                InspectieVM inspectieTemp = new InspectieVM(new Inspectie()
                {
                    Offerte    = SelectedOfferte.OfferteModel,          //TODO: Onnodig
                    Klant      = SelectedKlant.KlantModel,              //TODO: Onnodig
                    Gebruiker  = _dataServer._gebruiker.GebruikerModel, //TODO: Onnodig
                    Status     = statusTemp,                            //TODO: Onnodig
                    Datum      = this.Datum,                            //TODO: Change to selection (dataTimePicker)
                    Huisnummer = huisnummer,
                    Postcode   = PostCode,
                    Naam       = this.Naam,
                    Wens       = this.Wens,
                    Gebruiker1 = selectedGebruikers
                });

                InspectieRepository.AddInspection(inspectieTemp.InspectieModel);
                inspectionVM.InspectionList.Add(inspectieTemp);
                inspectionVM.RaisePropertyChanged();
                inspectionVM.UpdateInspecties();
                inspectionVM.CloseAddInspection();
            }
        }
        public ActionResult Open([Deserialize] VragenlijstViewModel wizard, IVragenlijstStap step)
        {
            wizard.Stappen[wizard.MomenteleStapIndex] = step;

            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(Request["next"]))
                {
                    wizard.MomenteleStapIndex++;
                }
                else
                {
                    var           json = new JavaScriptSerializer().Serialize(wizard);
                    VragenlijstVM tmp  = new VragenlijstVM()
                    {
                        Id = wizard.VragenlijstId
                    };
                    GebruikerVM gebruiker = new GebruikerVM()
                    {
                        Id = User.UserId
                    };
                    InspectieVM inspectie = new InspectieVM()
                    {
                        Id = wizard.InspectieId
                    };
                    (HttpContext.Application["dataServer"] as FestiSpecProvider).AddIngevuldeVragenlijst(inspectie, gebruiker, tmp, json);

                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View(wizard));
        }
示例#3
0
        public EditInspectionViewModel(InspectieViewModel inspection, FestiSpecProvider dataServer)
        {
            _previousPage = inspection;
            _dataServer   = dataServer;
            _inspection   = inspection.SelectedInspectie;

            Datum         = _inspection.Datum;
            GebruikerList = new ObservableCollection <GebruikerVM>();
            foreach (var g in _inspection.InspectieModel.Gebruiker1.ToList())
            {
                GebruikerVM gVM = new GebruikerVM(g);
                gVM.IsIncluded = true;
                GebruikerList.Add(gVM);
            }
            PostCode        = _inspection.Postcode;
            huisnummer      = _inspection.Huisnummer;
            Naam            = _inspection.Naam;
            Wens            = _inspection.Wens;
            SelectedKlant   = new KlantVM(_inspection.InspectieModel.Klant);
            SelectedStatus  = new StatusVM(_inspection.InspectieModel.Status);
            SelectedOfferte = new OfferteVM(_inspection.InspectieModel.Offerte);

            KlantList   = _dataServer.GetKlanten();
            StatusList  = _dataServer.GetStatus();
            OfferteList = _dataServer.GetOfferte().ToList();

            EditInspectionCommand = new RelayCommand(EditInspection);
            ShowMapCommand        = new RelayCommand(CalculateRoute);

            apiConnector = new GeodanRepository("6c4c63db-de9a-11e8-8aac-005056805b87");
        }
示例#4
0
        public void EditInspection()
        {
            if (Valid() && SelectedOfferte != null && SelectedKlant != null && SelectedStatus != null)
            {
                Status statusTemp = new Status();
                statusTemp.Naam = SelectedStatus.Naam;
                List <Gebruiker> selectedGebruikers = new List <Gebruiker>();
                GebruikerList.Where(g => g.IsIncluded)
                .ToList()
                .ForEach(g => selectedGebruikers.Add(g.GebruikerModel));

                InspectieVM inspectieTemp = new InspectieVM(new Inspectie()
                {
                    Id           = _inspection.Id,
                    Offerte      = SelectedOfferte.OfferteModel,
                    Klant        = SelectedKlant.KlantModel,
                    Gebruiker    = _dataServer._gebruiker.GebruikerModel,
                    Status       = statusTemp,
                    StatusNaam   = statusTemp.Naam,
                    KlantId      = SelectedKlant.Id,
                    OfferteId    = SelectedOfferte.Id,
                    Datum        = this.Datum,
                    RegistrantId = 4,
                    Huisnummer   = huisnummer,
                    Postcode     = PostCode,
                    Naam         = this.Naam,
                    Wens         = this.Wens,
                    Gebruiker1   = selectedGebruikers
                });

                _dataServer.UpdateInspectie(inspectieTemp.InspectieModel);
                _previousPage.InspectionList.Add(inspectieTemp);
                _previousPage.RaisePropertyChanged();
                _previousPage.UpdateInspecties();
                _previousPage.NotifyInspectieEdited(inspectieTemp.InspectieModel);
            }
        }
示例#5
0
 public InspectieVM AddInspection(InspectieVM inspectionToInsert)
 {
     return(new InspectieVM(InspectieRepository.AddInspection(inspectionToInsert.InspectieModel)));
 }
示例#6
0
 public void AddIngevuldeVragenlijst(InspectieVM inspectie, GebruikerVM user, VragenlijstVM originalVragenlijst, string data)
 {
     IngevuldeVragenlijstRepository.AddIngevuldeVragenlijst(inspectie.InspectieModel, user.GebruikerModel, originalVragenlijst.VragenlijstModel, data);
 }
        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);
        }