Exemple #1
0
        internal static void SaveFormFieldItem(FormFields formField)
        {
            using (FormsEntities formDAL = new FormsEntities())
            {
                if (formField.Id <= 0)
                {
                    formDAL.Entry(formField).State = System.Data.Entity.EntityState.Added;
                }
                else
                {
                    foreach (var option in formField.FormFieldsOptions)
                    {
                        if (option.Id <= 0)
                        {
                            formDAL.Entry(option).State = System.Data.Entity.EntityState.Added;
                        }
                        else
                        {
                            formDAL.Entry(option).State = System.Data.Entity.EntityState.Modified;
                        }
                    }

                    formDAL.Entry(formField).State = System.Data.Entity.EntityState.Modified;
                }

                formDAL.SaveChanges();
            }
        }
Exemple #2
0
        internal static void SaveForm(Form form)
        {
            using (FormsEntities formDAL = new FormsEntities())
            {
                if (form.Id > 0)
                {
                    foreach (var field in form.FormFields)
                    {
                        if (field.Id <= 0)
                        {
                            formDAL.Entry(field).State = System.Data.Entity.EntityState.Added;
                        }
                        else
                        {
                            foreach (var option in field.FormFieldsOptions)
                            {
                                if (option.Id <= 0)
                                {
                                    formDAL.Entry(option).State = System.Data.Entity.EntityState.Added;
                                }
                            }
                        }
                    }

                    formDAL.SaveChanges();
                    formDAL.Entry(form).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    formDAL.Form.Add(form);
                }

                foreach (var email in form.Form_Emails)
                {
                    if (email.Id > 0)
                    {
                        formDAL.Entry(email).State = System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        formDAL.Entry(email).State = System.Data.Entity.EntityState.Added;
                    }
                }

                formDAL.SaveChanges();
            }
        }
Exemple #3
0
 internal static void DeleteFormFieldItem(int formFieldId, int clubId)
 {
     using (FormsEntities formDAL = new FormsEntities())
     {
         FormFields field = formDAL.FormFields.Include("Form").FirstOrDefault(f => f.Id == formFieldId && f.Form.ClubId == clubId);
         if (field != null)
         {
             formDAL.Entry(field).State = System.Data.Entity.EntityState.Deleted;
             formDAL.SaveChanges();
         }
     }
 }
Exemple #4
0
 internal static void DeleteFormFieldOption(int optionId, int clubId)
 {
     //TODO: Make clubId check....
     using (FormsEntities formDAL = new FormsEntities())
     {
         FormFieldsOptions option = formDAL.FormFieldsOptions.FirstOrDefault(f => f.Id == optionId);
         if (option != null)
         {
             formDAL.Entry(option).State = System.Data.Entity.EntityState.Deleted;
             formDAL.SaveChanges();
         }
     }
 }
Exemple #5
0
 internal static void DeleteForm(int formId, int clubId)
 {
     using (FormsEntities formDAL = new FormsEntities())
     {
         Form form = formDAL.Form.FirstOrDefault(f => f.Id == formId && f.ClubId == clubId);
         if (form != null)
         {
             form.IsDeleted            = true;
             formDAL.Entry(form).State = System.Data.Entity.EntityState.Modified;
             formDAL.SaveChanges();
         }
     }
 }
Exemple #6
0
        internal static void DeleteExternalFormAnswer(string batch, int clubId)
        {
            using (FormsEntities formDAL = new FormsEntities())
            {
                var submitValues = formDAL.FormExternalSubmitValues.Include("Form").Where(f => f.Batch == batch && f.Form.ClubId == clubId);

                foreach (var item in submitValues)
                {
                    formDAL.Entry(item).State = System.Data.Entity.EntityState.Deleted;
                }

                formDAL.SaveChanges();
            }
        }