public Answer GetAnswer(Question question) { return(question switch { NumericQuestion _ => new NumericAnswer(), RatingQuestion _ => new NumericAnswer(), MultipleChoiceQuestion _ => new MultipleChoiceAnswer(), StringQuestion _ => new StringAnswer(), DrawQuestion _ => new FileAnswer(), UploadPictureQuestion _ => new FileAnswer(), _ => throw new Exception() });
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return(value switch { DrawQuestion _ => "Teken vraag", RatingQuestion _ => "Beoordelings vraag", StringQuestion _ => "Open vraag", MultipleChoiceQuestion _ => "Meerkeuze vraag", UploadPictureQuestion _ => "Foto vraag", NumericQuestion _ => "Numerieke vraag", ReferenceQuestion _ => "Referentie vraag", _ => "vraag" });
protected override void Seed(FestispecContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. // context.SaveChanges(); try { var address = new Address { Id = 1, StreetName = "Isolatorweg", HouseNumber = 36, ZipCode = "1014AS", City = "Amsterdam", Country = "Nederland", Latitude = 52.39399f, Longitude = 4.8507514f }; var address2 = new Address { Id = 2, Country = "Duitsland", StreetName = "Flughafen-Ring", HouseNumber = 16, City = "Weeze", ZipCode = "NW47652", Latitude = 51.5924149f, Longitude = 6.1545434f }; var address3 = new Address { Id = 3, City = "Utrecht", Country = "Nederland", HouseNumber = 59, StreetName = "Chopinstraat", ZipCode = "3533EL", Latitude = 52.0857048f, Longitude = 5.08541441f }; var address4 = new Address { City = "Amsterdam", Country = "Nederland", HouseNumber = 14, StreetName = "Lutmastraat", ZipCode = "1072JL", Latitude = 52.350400f, Longitude = 4.892710f }; context.Addresses.AddOrUpdate(address, address2, address3, address4); Employee employee = CreateEmployee(context, address3); var customer = new Customer { Id = 1, CustomerName = "Q-DANCE", KvkNr = 34212891, Address = address, ContactDetails = new ContactDetails { EmailAddress = "*****@*****.**", PhoneNumber = "+31204877300" } }; context.Customers.AddOrUpdate(customer); var now = DateTime.Now; var festival = new Festival { Id = 1, FestivalName = "Q-BASE", Customer = customer, Description = "Nachtfestival over de grens", Address = address2, OpeningHours = new OpeningHours { StartTime = new TimeSpan(now.Hour, now.Minute, now.Second), EndTime = new TimeSpan(8, 0, 0), StartDate = new DateTime(2020, 1, 1), EndDate = new DateTime(2020, 9, 6) } }; context.Festivals.AddOrUpdate(festival); customer.Festivals = new List <Festival> { festival }; context.Customers.AddOrUpdate(customer); var questionnaire = new Questionnaire { Id = 1, Name = "Tester", Festival = festival }; context.Questionnaires.AddOrUpdate(questionnaire); var employeeInspector = new Employee { Id = 2, Iban = "NL01RABO12789410", Name = new FullName { First = "Jan", Last = "Dirksen" }, Account = new Account { Id = 1, // Voorletter + Achternaam + geboortejaar Username = "******", Password = BCrypt.Net.BCrypt.HashPassword("TestWachtwoord"), Role = Role.Inspector }, Address = address4, ContactDetails = new ContactDetails { EmailAddress = "*****@*****.**", PhoneNumber = "+31987654321" }, Certificates = new List <Certificate> { new Certificate { Id = 2, CertificateTitle = "Inspection Certificate", CertificationDate = new DateTime(2019, 3, 4, 00, 00, 00), ExpirationDate = new DateTime(2021, 3, 4, 00, 00, 00) } } }; var plannedInspection = new PlannedInspection { Id = 1, Employee = employeeInspector, Festival = festival, EventTitle = "Inspection " + festival.FestivalName, StartTime = DateTime.Now.Date.Add(new TimeSpan(0, 10, 0, 0)), EndTime = DateTime.Now.Date.Add(new TimeSpan(0, 20, 0, 0)), Questionnaire = questionnaire, }; context.PlannedInspections.AddOrUpdate(plannedInspection); #region DrawQuestion var drawQuestion = new DrawQuestion { Id = 1, PicturePath = "/Uploads/grasso.png", Questionnaire = questionnaire, Contents = "Wat is de kortste looproute van de mainstage naar de nooduitgang?" }; var drawQuestionAnswer = new FileAnswer { Id = 1, Question = drawQuestion, UploadedFilePath = "/Uploads/inspection_adsfadfs.png", PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(drawQuestionAnswer); context.Questions.AddOrUpdate(drawQuestion); #endregion #region MultipleChoiceQuestion var multipleChoiceQuestion = new MultipleChoiceQuestion { Id = 2, Contents = "Zijn er evacuatieplannen zichtbaar opgesteld?", Options = "Ja~Nee", OptionCollection = new ObservableCollection <StringObject> { new StringObject("Option1") }, Questionnaire = questionnaire }; var multipleChoiceQuestionAnswer = new MultipleChoiceAnswer { Id = 2, MultipleChoiceAnswerKey = 0, PlannedInspection = plannedInspection, Question = multipleChoiceQuestion }; context.Answers.AddOrUpdate(multipleChoiceQuestionAnswer); context.Questions.AddOrUpdate(multipleChoiceQuestion); #endregion #region NumericQuestion var numericQuestion = new NumericQuestion { Id = 3, Contents = "Hoeveel EHBO-posten zijn er aanwezig?", Minimum = 0, Maximum = 99, Questionnaire = questionnaire }; var numericQuestionAnswer = new NumericAnswer { Id = 3, Question = numericQuestion, IntAnswer = 3, PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(numericQuestionAnswer); context.Questions.AddOrUpdate(numericQuestion); #endregion #region RatingQuestion var ratingQuestion = new RatingQuestion { Id = 4, Contents = "Op een schaal van 1 tot 5, is de beveiliging voldoende aanwezig op het terrein?", HighRatingDescription = "Er is veel beveiliging", LowRatingDescription = "Er is amper beveiliging", Questionnaire = questionnaire }; var ratingQuestionAnswer = new NumericAnswer { Id = 3, Question = numericQuestion, IntAnswer = 4, PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(ratingQuestionAnswer); context.Questions.AddOrUpdate(ratingQuestion); #endregion #region StringQuestion var stringQuestion = new StringQuestion { Id = 5, Contents = "Geef een korte samenvatting van het vluchtplan.", IsMultiline = true, Questionnaire = questionnaire }; var stringQuestionAnswer = new StringAnswer { Id = 5, Question = stringQuestion, AnswerContents = "In geval van een calamiteit is voor de bezoekers duidelijk te zien dat er vanaf de mainstage al vier vluchtroutes bestaan.", PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(stringQuestionAnswer); context.Questions.AddOrUpdate(stringQuestion); #endregion #region PictureQuestion var pictureQuestion = new UploadPictureQuestion { Id = 6, Contents = "Plaats een foto van de vluchtroutes op het calamiteitenplan.", Questionnaire = questionnaire }; var pictureQuestionAnswer = new FileAnswer { Id = 6, Question = pictureQuestion, UploadedFilePath = "/uploads/inspection_adsfadfs.png", PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(pictureQuestionAnswer); context.Questions.AddOrUpdate(pictureQuestion); #endregion #region ReferenceQuestion var referenceQuestion = new ReferenceQuestion { Id = 7, Question = pictureQuestion, Contents = pictureQuestion.Contents, Questionnaire = questionnaire }; var referenceQuestionAnswer = new FileAnswer { Id = 7, Question = referenceQuestion, UploadedFilePath = "/uploads/inspection_eruwioeiruwoio.png", PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(referenceQuestionAnswer); context.Questions.AddOrUpdate(referenceQuestion); #endregion context.Employees.AddOrUpdate(employeeInspector); context.SaveChanges(); } catch (DbEntityValidationException e) { foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }
public SessionEvaluationRating Rating(RatingQuestion question) { return(Community.AddFact(new SessionEvaluationRating(this, question))); }