Exemple #1
0
        public void TestSaveForm()
        {
            var form = new FormDTO();

            form.Type     = FormType.AankoopBegeleiding;
            form.Fullname = "Tahos Facaj";
            FormDAO.SaveForm(form);
            var forms = FormDAO.LoadActiveForms <FormDTO>(FormType.AankoopBegeleiding);

            Assert.AreEqual(1, forms.Count);
            Assert.AreEqual("Tahos Facaj", forms[0].Fullname);
        }
Exemple #2
0
 public void SetEmailSent(FormDTO form, bool sent)
 {
     using (var connection = Provider.CreateConnection())
     {
         connection.ConnectionString = ConnectionString;
         connection.Open();
         using (var command = Provider.CreateCommand())
         {
             command.Connection  = connection;
             command.CommandText = $"UPDATE {form.Type.GetTableName()} SET sent = @sent WHERE id = @id";
             command.SetParameter("sent", sent);
             command.SetParameter("id", form.id);
             command.ExecuteNonQuery();
         }
     }
 }
Exemple #3
0
        public string BodyBuilderFormDTO(FormDTO formDTO)
        {
            string body = $"De volgende aanvraag {formDTO.Type.GetDescription()} werd ingediend,{Environment.NewLine}{Environment.NewLine}Gegevens:{Environment.NewLine}";


            PropertyInfo[] properties = typeof(FormDTO).GetProperties();

            foreach (PropertyInfo property in properties)
            {
                var name = property.GetCustomAttribute <NLNameAttribute>();
                if (name != null)
                {
                    body = body + $"{name.NLName}   {property.GetValue(formDTO)}{Environment.NewLine}";
                }
            }

            return(body);
        }
Exemple #4
0
 public void SaveForm(FormDTO form)
 {
     using (var connection = Provider.CreateConnection())
     {
         connection.ConnectionString = ConnectionString;
         connection.Open();
         using (var command = Provider.CreateCommand())
         {
             command.Connection  = connection;
             command.CommandText = $"insert into {form.Type.GetTableName()} (VERSION, ATTRS) values (@V, @A::json)";
             command.SetParameter("V", 0);
             var memstream = new MemoryStream();
             Json.WriteObject(memstream, form);
             memstream.Position = 0;
             var reader = new StreamReader(memstream);
             command.SetParameter("A", reader.ReadToEnd());
             command.ExecuteNonQuery();
         }
     }
 }