Example #1
0
        public async Task <IActionResult> Create()
        {
            var cancellationToken = HttpContext.RequestAborted;
            var form     = HttpContext.Request.Form;
            var settings = JsonConvert.DeserializeObject <ProjectSettings>(form["settings"]);
            var data     = await mediator.Send(new GetProjectDataFromFormQuery()
            {
                Settings = settings,
                File     = form.Files.Count > 0 ? form.Files[0].OpenReadStream() : null
            }, cancellationToken);

            var errors = Validate(settings, false);

            if (errors.Count == 0)
            {
                projectManager.AddProject(settings);
                if (data != null)
                {
                    await mediator.Send(new ImportProjectCommand()
                    {
                        Data = data
                    }, cancellationToken);
                }
            }

            return(Ok(errors));
        }
        public async Task <IActionResult> PostNewProject([FromForm] NewProjectDto newProj, [FromRoute] string orgId)
        {
            try
            {
                _unitOfWorkManager.StartUnitOfWork();

                Project p = _projectManager.AddProject(
                    newProj.Title,
                    newProj.StartDate,
                    newProj.EndDate,
                    newProj.OrganisationId);

                foreach (var video in newProj.Videos)
                {
                    string imgLocation = await _fileService.ConvertFileToLocation(video);

                    _ideationManager.AddFieldToProject(FieldType.Video, imgLocation, p.ProjectId);
                }

                foreach (var image in newProj.Images)
                {
                    string imgLocation = await _fileService.ConvertFileToLocation(image);

                    _ideationManager.AddFieldToProject(FieldType.Picture, imgLocation, p.ProjectId);
                }

                foreach (var textfield in newProj.Texts)
                {
                    _ideationManager.AddFieldToProject(FieldType.Text, textfield, p.ProjectId);
                }

                foreach (var location in newProj.Locations)
                {
                    _ideationManager.AddFieldToProject(FieldType.Location, location, p.ProjectId);
                }

                foreach (var link in newProj.Links)
                {
                    _ideationManager.AddFieldToProject(FieldType.Link, link, p.ProjectId);
                }

                _unitOfWorkManager.EndUnitOfWork();

                return(CreatedAtAction(
                           "GetProject",
                           new { orgId, id = p.ProjectId },
                           _mapper.Map <ProjectDto>(p)));
            }
            catch (ValidationException ve)
            {
                return(UnprocessableEntity($"Invalid input data: {ve.ValidationResult.ErrorMessage}"));
            }
            catch (Exception e)
            {
                return(BadRequest($"Something went wrong in creating the project: {e.Message}."));
            }
        }
Example #3
0
        //CREATE project
        public async Task <IActionResult> CreateProject(ProjectViewModel model)
        {
            if (ModelState.IsValid)
            {
                //DIT GEBRUIKEN VANAF PAGINA AF IS
                //var user = await _userManager.GetUserAsync(User);

                //Test ophalen admin
                var user = await _userManager.FindByEmailAsync("admin@localhost");

                var platform = user.Platform.Id;
                _projectManager.AddProject(
                    model.Title,
                    model.Location,
                    model.Content,
                    model.StartDate,
                    model.EndDate,
                    user,
                    user.Platform
                    );
                return(View());
            }
            return(View());
        }
Example #4
0
        /// <summary>
        /// Injects test data into the application. This will only run if the Superadmin (created on startup) is the
        /// only user in the application.
        /// </summary>
        /// <returns></returns>
        public async Task Seed()
        {
            // cancel if there's more data present than just the superadmin created by the role seed
            if (_userService.NumberOfUsers() > 1)
            {
                return;
            }

            try
            {
                Random rnd = new Random();

                #region Organisations

                List <Organisation> organisations = new List <Organisation>();

                organisations.Add(_organisationManager.AddOrganisation("District Antwerpen",
                                                                       "districtantwerpen",
                                                                       "Centraal gelegen district in de provincie Antwerpen",
                                                                       "#d11f38"));
                _organisationManager.AddImageToOrganisation(organisations.Last().OrganisationId, "/img/antwerp.jpeg");
                _organisationManager.AddLogoToOrganisation(organisations.Last().OrganisationId, "/img/logo_antwerp.png");
                organisations.Add(_organisationManager.AddOrganisation("Brussel",
                                                                       "brussels",
                                                                       "Hoofdstad",
                                                                       "#00027f"));
                _organisationManager.AddImageToOrganisation(organisations.Last().OrganisationId, "/img/brussel.jpg");
                _organisationManager.AddLogoToOrganisation(organisations.Last().OrganisationId, "/img/logo_brussels.png");

                #endregion

                #region Users

                List <User> users = new List <User>();

                users.Add(await _userService.RegisterNewUser("*****@*****.**", "testtest1", "Kristof", "Buts", Gender.Male, new DateTime(1996, 6, 2), 2222, organisations[0].Identifier));
                _userManager.AddPictureLocationToUser(users.Last().Id, "/img/Profile_1.jpeg");

                users.Add(await _userService.RegisterNewUser("*****@*****.**", "testtest1", "Emre", "Arslan", Gender.Male, new DateTime(1996, 6, 2), 2222, organisations[0].Identifier));
                _userManager.AddPictureLocationToUser(users.Last().Id, "/img/Profile_3.jpeg");

                users.Add(await _userService.RegisterNewUser("*****@*****.**", "testtest1", "Jordy", "Bruyns", Gender.Male, new DateTime(1996, 6, 2), 2222, organisations[0].Identifier));
                _userManager.AddPictureLocationToUser(users[2].Id, "/img/Profile_4.jpeg");

                users.Add(await _userService.RegisterNewUser("*****@*****.**", "testtest1", "Ian", "Jakubek", Gender.Male, new DateTime(1996, 6, 2), 2222, organisations[0].Identifier));
                _userManager.AddPictureLocationToUser(users[3].Id, "/img/Profile_5.jpeg");

                users.Add(await _userService.RegisterNewUser("*****@*****.**", "testtest1", "Wout", "Peeters", Gender.Male, new DateTime(1996, 6, 2), 2222, organisations[0].Identifier));
                _userManager.AddPictureLocationToUser(users[4].Id, "/img/Profile_6.jpeg");

                users.Add(await _userService.RegisterNewUser("*****@*****.**", "testtest1", "Jana", "Wouters", Gender.Female, new DateTime(1996, 6, 2), 2222, organisations[0].Identifier));
                _userManager.AddPictureLocationToUser(users[5].Id, "/img/Profile_2.jpeg");

                await _userService.AddUserToOrganisation(users[1].Id, organisations[1].Identifier);

                #endregion

                #region Projects

                List <Project> projects = new List <Project>();

                // open project sample
                projects.Add(_projectManager.AddProject("Vrijbroekspark",
                                                        new DateTime(2019, 2, 16),
                                                        new DateTime(2019, 7, 1),
                                                        organisations[0].OrganisationId));
                _ideationManager.AddFieldToProject(FieldType.Text,
                                                   "In onze gemeente hebben we een prachtig park. Beslis mee over dit prachtige park.",
                                                   projects.Last().ProjectId);
                _ideationManager.AddFieldToProject(FieldType.Picture,
                                                   "/img/park.jpg",
                                                   projects.Last().ProjectId);

                // closed project
                projects.Add(_projectManager.AddProject("Haven van Antwerpen",
                                                        new DateTime(2019, 2, 16),
                                                        new DateTime(2019, 3, 12),
                                                        organisations[0].OrganisationId));
                _ideationManager.AddFieldToProject(FieldType.Text,
                                                   "De haven van Antwerpen is toe aan vernieuwingen, hoe moeten deze gebeuren?",
                                                   projects.Last().ProjectId);
                _ideationManager.AddFieldToProject(FieldType.Picture,
                                                   "/img/haven.jpg",
                                                   projects.Last().ProjectId);

                // closed project
                projects.Add(_projectManager.AddProject("Fietspaden",
                                                        new DateTime(2019, 2, 20),
                                                        new DateTime(2019, 4, 1),
                                                        organisations[0].OrganisationId));
                _ideationManager.AddFieldToProject(FieldType.Text,
                                                   "Wij hechten veel belang aan de veiligheid van de zwakke gebruiker.",
                                                   projects.Last().ProjectId);
                _ideationManager.AddFieldToProject(FieldType.Picture,
                                                   "/img/slechtfietspad.jpg",
                                                   projects.Last().ProjectId);

                // open project
                projects.Add(_projectManager.AddProject("Beleid voor elektrische steps",
                                                        new DateTime(2019, 5, 15),
                                                        new DateTime(2019, 7, 15),
                                                        organisations[0].OrganisationId));
                _ideationManager.AddFieldToProject(FieldType.Text,
                                                   "Bedrijven als BIRD duiken snel overal op, hoe gaan we hier best mee om?",
                                                   projects.Last().ProjectId);
                _ideationManager.AddFieldToProject(FieldType.Picture,
                                                   "/img/bird.jpg",
                                                   projects.Last().ProjectId);


                #endregion

                #region ProjectPhases

                List <ProjectPhase> phases = new List <ProjectPhase>();

                #region Vrijbroekspark
                phases.Add(_projectManager.AddProjectPhase("Project setup", "De setup van het Vrijbroekspark",
                                                           new DateTime(2019, 2, 16), new DateTime(2019, 4, 20), projects[0].ProjectId));
                phases.Add(_projectManager.AddProjectPhase("Bank plaatsen", "Het bankje plaatsen",
                                                           new DateTime(2019, 4, 21), new DateTime(2019, 5, 1), projects[0].ProjectId));
                phases.Add(_projectManager.AddProjectPhase("Afwerking bank", "Het bankje afwerken en controleren",
                                                           new DateTime(2019, 5, 2), new DateTime(2019, 7, 1), projects[0].ProjectId));
                #endregion

                #region Haven
                phases.Add(_projectManager.AddProjectPhase("Bepalen budget", "Hoeveel kunnen we investeren?",
                                                           new DateTime(2019, 2, 16), new DateTime(2019, 2, 22), projects[1].ProjectId));
                phases.Add(_projectManager.AddProjectPhase("Bepalen planning", "Op welke termijn moeten de werken gebeuren?",
                                                           new DateTime(2019, 2, 23), new DateTime(2019, 3, 1), projects[1].ProjectId));
                phases.Add(_projectManager.AddProjectPhase("Opvragen offertes", "Wie kan de werken uitvoeren?",
                                                           new DateTime(2019, 3, 2), new DateTime(2019, 3, 12), projects[1].ProjectId));
                #endregion

                #region Fietspaden
                phases.Add(_projectManager.AddProjectPhase("Bepalen budget", "De setup van het Vrijbroekspark",
                                                           new DateTime(2019, 2, 20), new DateTime(2019, 3, 1), projects[2].ProjectId));
                phases.Add(_projectManager.AddProjectPhase("Bepalen prioriteiten", "Waar moet er het snelst een nieuw fietspad komen?",
                                                           new DateTime(2019, 3, 2), new DateTime(2019, 3, 19), projects[2].ProjectId));
                phases.Add(_projectManager.AddProjectPhase("Opmaken planning", "Wanneer kunnen we de werken uitvoeren?",
                                                           new DateTime(2019, 3, 20), new DateTime(2019, 4, 1), projects[2].ProjectId));
                #endregion

                #region Steps
                phases.Add(_projectManager.AddProjectPhase("Verzamelen data", "Informatie inwinnen bij de betrokken instanties.",
                                                           new DateTime(2019, 5, 15), new DateTime(2019, 6, 14), projects[3].ProjectId));
                phases.Add(_projectManager.AddProjectPhase("Uitschrijven beleid", "Bepalen van de wettelijke context.",
                                                           new DateTime(2019, 6, 15), new DateTime(2019, 7, 15), projects[3].ProjectId));
                #endregion

                #endregion

                #region Ideations

                List <Ideation> ideations = new List <Ideation>();
                List <Field>    fields    = new List <Field>();

                #region Project 1

                #region Phase 1

                ideations.Add(_ideationManager.AddIdeation("Kleur kiezen",
                                                           phases[0].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text, "De kleur van de banken kiezen", ideations.Last().IdeationId));

                ideations.Add(_ideationManager.AddIdeation("Materiaal kiezen",
                                                           phases[0].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text,
                                                               "Het materiaal waarin de banken gemaakt moeten worden kiezen", ideations.Last().IdeationId));

                #endregion

                #region Phase 2
                ideations.Add(_ideationManager.AddIdeation("Locatie bepalen",
                                                           phases[1].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text,
                                                               "De exacte locatie van de banken bepalen", ideations.Last().IdeationId));

                ideations.Add(_ideationManager.AddIdeation("Hoeveelheid",
                                                           phases[1].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text,
                                                               "Het aantal banken dat geplaatst moet worden bepalen", ideations.Last().IdeationId));

                ideations.Add(_ideationManager.AddIdeation("Afmetingen",
                                                           phases[1].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text,
                                                               "De grootte, lengte en breedte van de banken bepalen", ideations.Last().IdeationId));
                #endregion

                #region Phase 3
                ideations.Add(_ideationManager.AddIdeation("Inspectie",
                                                           phases[2].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text,
                                                               "De geplaatste bankjes inspecteren op correcte specificaties", ideations.Last().IdeationId));
                #endregion

                #endregion

                #region Project 2

                #region Phase 1
                ideations.Add(_ideationManager.AddIdeation("Hoe bepalen we het budget?",
                                                           phases[3].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text, "Wat is de eerlijkste manier om een budget vast te leggen?", ideations.Last().IdeationId));
                #endregion

                #region Phase 2
                ideations.Add(_ideationManager.AddIdeation("Wat met overlast?",
                                                           phases[4].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text, "Hoe pakken we de hinder aan?", ideations.Last().IdeationId));
                ideations.Add(_ideationManager.AddIdeation("Welke strategie volgen we?",
                                                           phases[4].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text, "Heel snel of langer verspreiden om minder hinder te veroorzaken?", ideations.Last().IdeationId));
                #endregion

                #region Phase 3
                ideations.Add(_ideationManager.AddIdeation("Toekenningscriteria",
                                                           phases[5].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text, "Waarmee gaan we rekening houden bij het kiezen van een aannemer?", ideations.Last().IdeationId));
                ideations.Add(_ideationManager.AddIdeation("Wie contacteren?",
                                                           phases[5].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text, "Waar kunnen we een offerte vragen?", ideations.Last().IdeationId));
                #endregion

                #endregion

                #region Project 4

                #region Phase 1
                ideations.Add(_ideationManager.AddIdeation("Kritieke factoren",
                                                           phases[9].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text, "Wat zijn de beslissende factoren in dergelijk beleid?",
                                                               ideations.Last().IdeationId));
                #endregion

                #region Phase 2
                ideations.Add(_ideationManager.AddIdeation("Maximumsnelheid",
                                                           phases[10].ProjectPhaseId));
                fields.Add(_ideationManager.AddFieldToIdeation(FieldType.Text, "Wat is een realistische toegelaten maximumsnelheid?",
                                                               ideations.Last().IdeationId));
                #endregion

                #endregion

                #endregion

                #region Ideas

                List <Idea> ideas = new List <Idea>();

                #region Project 1
                #region Ideation 1
                ideas.Add(_ideationManager.AddIdea("Blauwe banken",
                                                   ideations[0].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Ik vind dat de kleur van de banken blauw moet zijn.", ideas[0].IdeaId));


                ideas.Add(_ideationManager.AddIdea("Bruine banken",
                                                   ideations[0].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Ik vind dat de kleur van de banken bruin moet zijn.", ideas[1].IdeaId));


                ideas.Add(_ideationManager.AddIdea("Grijze banken",
                                                   ideations[0].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Ik vind dat de kleur van de banken grijs moet zijn.", ideas[2].IdeaId));

                #endregion
                #region Ideation 2

                ideas.Add(_ideationManager.AddIdea("Houten banken met metalen leuning",
                                                   ideations[1].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Banken gemaakt van een lokale houtsoort met een metale leuning lijkt mij het beste.", ideas[3].IdeaId));

                #endregion
                #region Ideation 3
                ideas.Add(_ideationManager.AddIdea("Dicht bij het meer",
                                                   ideations[2].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Ik zou het tof vinden als de banken dicht bij het meer staan.", ideas[4].IdeaId));
                #endregion
                #region Ideation 4
                ideas.Add(_ideationManager.AddIdea("3 keer dubbele banken",
                                                   ideations[3].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Ik wil telkens 2 banken tegen elkaar, en in totaal 3 keer.", ideas[5].IdeaId));
                #endregion
                #region Ideation 5
                ideas.Add(_ideationManager.AddIdea("2 meter lang per bank",
                                                   ideations[4].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Mij lijkt de ideale lengte 2 meter, zo kunnen er voldoende mensen op 1 bank zitten, en nemen ze niet teveel plaats in beslag.", ideas[6].IdeaId));
                #endregion
                #region Ideation 6
                ideas.Add(_ideationManager.AddIdea("Controleren of het aantal klopt",
                                                   ideations[5].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Er moet zeker worden nagekeken of de hoeveelheid banken juist is.", ideas[7].IdeaId));
                #endregion
                #endregion

                #region Haven

                #region Ideation 7
                ideas.Add(_ideationManager.AddIdea("1% van het BBP",
                                                   ideations[6].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Een economisch haalbare investering.", ideas.Last().IdeaId));
                ideas.Add(_ideationManager.AddIdea("10% van de belastingsinkomst van elke Antwerpenaar",
                                                   ideations[6].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "De haven is positief voor iedereen, en daar moeten we stevig in investeren..", ideas.Last().IdeaId));
                #endregion
                #region Ideation 8
                ideas.Add(_ideationManager.AddIdea("Alles autovrij tijdens de werken",
                                                   ideations[7].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "We kiezen voor de veiligheid van onze werknemers en maken alles autovrij.", ideas.Last().IdeaId));
                #endregion
                #region Ideation 9
                ideas.Add(_ideationManager.AddIdea("Over lange termijn spreiden",
                                                   ideations[8].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "We proberen de overlast te minimaliseren", ideas.Last().IdeaId));
                ideas.Add(_ideationManager.AddIdea("Alles autovrij tijdens de werken",
                                                   ideations[8].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "We kiezen voor de veiligheid van onze werknemers en maken alles autovrij.", ideas.Last().IdeaId));
                #endregion
                #region Ideation 10
                ideas.Add(_ideationManager.AddIdea("Bekwaamheid",
                                                   ideations[9].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Kwaliteit van het werk primeert", ideas.Last().IdeaId));
                ideas.Add(_ideationManager.AddIdea("Prijs",
                                                   ideations[9].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Zo goedkoop mogelijk", ideas.Last().IdeaId));
                #endregion
                #region Ideation 11
                ideas.Add(_ideationManager.AddIdea("Jan Peeters",
                                                   ideations[10].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Ik ken hem al lang, levert mooi werk", ideas.Last().IdeaId));
                ideas.Add(_ideationManager.AddIdea("Havenwerken nv",
                                                   ideations[10].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Gespecialiseerd in havenwerken", ideas.Last().IdeaId));
                #endregion

                #endregion

                #region Fietspaden
                #endregion

                #region Steps
                #region Ideation 12
                ideas.Add(_ideationManager.AddIdea("Veiligheid van de zwakke weggebruiker",
                                                   ideations[11].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Voetgangers mogen hier geen hinder van ondervinden", ideas.Last().IdeaId));
                ideas.Add(_ideationManager.AddIdea("Straatbeeld",
                                                   ideations[11].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Die BIRDs slingeren overal rond, ze verknoeien het Antwerpse straatbeeld.", ideas.Last().IdeaId));
                #endregion
                #region Ideation 13
                ideas.Add(_ideationManager.AddIdea("10 km/h",
                                                   ideations[12].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Ik vind ze heel onveilig, ze moeten veel trager.", ideas.Last().IdeaId));
                ideas.Add(_ideationManager.AddIdea("50 km/h",
                                                   ideations[12].IdeationId));
                fields.Add(_ideationManager.AddFieldToIdea(FieldType.Text, "Met de nodige verantwoordelijkheid is een hoge maximumsnelheid geen probleem.", ideas.Last().IdeaId));
                #endregion

                #endregion

                #endregion

                #region Comments

                // comments are generated randomly by using strings from the array declared above
                List <Comment> comments = new List <Comment>();

                for (int i = 0; i < 100; ++i)
                {
                    comments.Add(_cityOfIdeasController.AddCommentToIdea(
                                     users[rnd.Next(users.Count)].Id,            // random user id
                                     ideas[rnd.Next(ideas.Count)].IdeaId         // random idea id
                                     ));
                    fields.Add(_ideationManager.AddFieldToComment(FieldType.Text, CommentAnswers[rnd.Next(CommentAnswers.Length)], comments.Last().CommentId));
                }

                #endregion

                #region Votes
                List <Vote> votes = new List <Vote>();

                // generate random user votes
                for (int i = 0; i < 100; ++i)
                {
                    // 80% upvotes
                    int voteValue = 1;
                    if (i % 5 == 0)
                    {
                        voteValue = -1;
                    }

                    votes.Add(_cityOfIdeasController.AddVoteToIdea(
                                  voteValue,
                                  users[rnd.Next(users.Count)].Id,               // random user id
                                  null,
                                  ideas[rnd.Next(ideas.Count)].IdeaId));         // random idea id
                }

                // generate random anonymous votes
                for (int i = 0; i < 500; ++i)
                {
                    // 80% upvote
                    int voteValue = 1;
                    if (i % 5 == 0)
                    {
                        voteValue = -1;
                    }
                    votes.Add(_cityOfIdeasController.AddVoteToIdea(
                                  voteValue,
                                  null,
                                  null,
                                  ideas[rnd.Next(ideas.Count)].IdeaId));               // random idea id
                }

                #endregion

                #region Questionnaires

                List <Questionnaire> questionnaires = new List <Questionnaire>();
                List <Question>      questions      = new List <Question>();
                List <Option>        options        = new List <Option>();

                #region Project 1

                #region Questionnaire 1
                questionnaires.Add(_questionnaireManager.AddQuestionnaire("Usability evaluation", "Beste bezoeker, In volgende enquete willen wij graag de tevredenheid bij het gebruik van onze website bevragen.", phases[1].ProjectPhaseId));

                questions.Add(_questionnaireManager.AddQuestion("Hoe heeft u onze website gevonden?",
                                                                true, QuestionType.MultipleChoice, questionnaires[0].QuestionnaireId));
                options.Add(_questionnaireManager.AddOption("Zoekmachine", questions[0].QuestionId));
                options.Add(_questionnaireManager.AddOption("Sociale media", questions[0].QuestionId));
                options.Add(_questionnaireManager.AddOption("Online advertentie", questions[0].QuestionId));
                options.Add(_questionnaireManager.AddOption("Via vrienden of kennissen", questions[0].QuestionId));
                questions.Add(_questionnaireManager.AddQuestion("Is onze website makkelijk te gebruiken?",
                                                                true, QuestionType.SingleChoice, questionnaires[0].QuestionnaireId));
                options.Add(_questionnaireManager.AddOption("Ja", questions[1].QuestionId));
                options.Add(_questionnaireManager.AddOption("Neen", questions[1].QuestionId));
                questions.Add(_questionnaireManager.AddQuestion("Wat vindt u van het design van onze website",
                                                                true, QuestionType.OpenQuestion, questionnaires[0].QuestionnaireId));
                #endregion

                #region Questionnaire 2
                questionnaires.Add(_questionnaireManager.AddQuestionnaire("Bevraging elektische steps", "Graag hadden we mee informatie ingewonnen over de populariteit van elektrische steps.", phases[9].ProjectPhaseId));

                questions.Add(_questionnaireManager.AddQuestion("Welke van onderstaande diensten heeft u reeds gebruikt?", true, QuestionType.MultipleChoice, questionnaires.Last().QuestionnaireId));
                options.Add(_questionnaireManager.AddOption("BIRD", questions.Last().QuestionId));
                options.Add(_questionnaireManager.AddOption("Lime", questions.Last().QuestionId));
                options.Add(_questionnaireManager.AddOption("Poppy", questions.Last().QuestionId));

                questions.Add(_questionnaireManager.AddQuestion("Verplicht een helm dragen?", true, QuestionType.SingleChoice, questionnaires.Last().QuestionnaireId));
                options.Add(_questionnaireManager.AddOption("Ja", questions.Last().QuestionId));
                options.Add(_questionnaireManager.AddOption("Neen", questions.Last().QuestionId));

                questions.Add(_questionnaireManager.AddQuestion("Wat is uw mening over de elektrische step in het straatbeeld?",
                                                                true, QuestionType.OpenQuestion, questionnaires.Last().QuestionnaireId));

                #endregion

                #region Questionnaire 3
                questionnaires.Add(_questionnaireManager.AddQuestionnaire("Bevraging uitbreiding haven", "Graag hadden we uw mening gehoord over de uitbreiding van de haven", phases[3].ProjectPhaseId));

                questions.Add(_questionnaireManager.AddQuestion("Wat vindt u van de uitbreiding van de haven?", true, QuestionType.OpenQuestion, questionnaires.Last().QuestionnaireId));

                questions.Add(_questionnaireManager.AddQuestion("Waaraan moeten we hoogste prioriteit geven?", true, QuestionType.Dropdown, questionnaires.Last().QuestionnaireId));
                options.Add(_questionnaireManager.AddOption("Doorvoer verhogen", questions.Last().QuestionId));
                options.Add(_questionnaireManager.AddOption("Overlast minimaliseren", questions.Last().QuestionId));
                options.Add(_questionnaireManager.AddOption("Drugstraffiek aanpakken", questions.Last().QuestionId));

                questions.Add(_questionnaireManager.AddQuestion("Wat zou u doen om de vervuiling door de haven te verminderen?",
                                                                true, QuestionType.OpenQuestion, questionnaires.Last().QuestionnaireId));

                #endregion

                #endregion

                #endregion
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }
        }
Example #5
0
        public async Task <IActionResult> Post([FromForm] ProjectDTO projectDto)
        {
            if (ModelState.IsValid)
            {
                var phases = new List <Phase>();

                projectDto.Phases.ForEach(phaseDto =>
                {
                    var phase = new Phase()
                    {
                        Number      = phaseDto.Number,
                        Title       = phaseDto.Title,
                        Description = phaseDto.Description,
                    };

                    phases.Add(phase);
                });

                var fileName = Util.Util.GenerateDataStoreObjectName(projectDto.Logo.FileName);
                var imageObj = new Media()
                {
                    Name = fileName,
                    Url  = await _fileUploader.UploadFile(fileName, "project-logos", projectDto.Logo),
                };

                var platform = _platformManager.GetPlatformByTenant(projectDto.PlatformTenant);


                var project = new Project()
                {
                    Title              = projectDto.Title,
                    Goal               = projectDto.Goal,
                    Logo               = imageObj,
                    Phases             = phases,
                    Platform           = platform,
                    StartDate          = projectDto.StartDate,
                    EndDate            = projectDto.EndDate,
                    CurrentPhaseNumber = projectDto.CurrentPhase
                };

                if (projectDto.CurrentPhase > projectDto.Phases.Count)
                {
                    project.CurrentPhaseNumber = 0;
                }

                if (projectDto.Moderators != null)
                {
                    foreach (string moderatorUserName in projectDto.Moderators)
                    {
                        User mod = _userManager.FindByNameAsync(moderatorUserName).Result;
                        if (mod != null)
                        {
                            ProjectModerator moderator = new ProjectModerator()
                            {
                                Project = project,
                                User    = mod
                            };
                            project.Moderators.Add(moderator);
                        }
                    }
                }

                platform.Projects.Add(project);
                _projectManager.AddProject(project);
                _unitOfWorkManager.Save();
                return(Created("/project/details/" + project.ProjectId, new { id = project.ProjectId }));
            }

            return(StatusCode(400));
        }