public static void CreateSubmission(string formAlias, Dictionary <string, string> submissionContent) { int formID = GetFormIDFromAlias(formAlias); if (formID > -1) { FormStorageSubmissionModel formStorageSubmission = new FormStorageSubmissionModel(); formStorageSubmission.FormID = formID; formStorageSubmission.IP = GetUserIP(); formStorageSubmission.Datetime = DateTime.Now; using (IScope scope = Current.ScopeProvider.CreateScope()) { IUmbracoDatabase DatabaseConnection = scope.Database; try { DatabaseConnection.Save(formStorageSubmission); } catch (Exception ex) { Current.Logger.Error <FormStorageController>("Unable to save to FormStorageSubmissions table : {message}", ex.Message); return; } foreach (KeyValuePair <string, string> currentField in submissionContent) { FormStorageEntryModel formStorageEntry = new FormStorageEntryModel(); formStorageEntry.SubmissionID = formStorageSubmission.SubmissionID; formStorageEntry.FieldAlias = currentField.Key; formStorageEntry.Value = !string.IsNullOrEmpty(currentField.Value) ? currentField.Value : string.Empty; try { DatabaseConnection.Save(formStorageEntry); } catch (Exception ex) { Current.Logger.Error <FormStorageController>("Unable to save to FormStorageEntries table : {message}", ex.Message); } } scope.Complete(); } } }
public static void CreateSubmission(string formAlias, Dictionary <string, string> submissionContent) { int formID = GetFormIDFromAlias(formAlias); if (formID > -1) { FormStorageSubmissionModel formStorageSubmission = new FormStorageSubmissionModel(); formStorageSubmission.FormID = formID; formStorageSubmission.IP = GetUserIP(); formStorageSubmission.Datetime = DateTime.Now; try { DatabaseConnection.Save(formStorageSubmission); } catch (Exception ex) { Log.Error("Unable to save to FormStorageSubmissions table : " + ex.Message); return; } foreach (KeyValuePair <string, string> currentField in submissionContent) { FormStorageEntryModel formStorageEntry = new FormStorageEntryModel(); formStorageEntry.SubmissionID = formStorageSubmission.SubmissionID; formStorageEntry.FieldAlias = currentField.Key; formStorageEntry.Value = !string.IsNullOrEmpty(currentField.Value) ? currentField.Value : string.Empty; try { DatabaseConnection.Save(formStorageEntry); } catch (Exception ex) { Log.Error("Unable to save to FormStorageEntries table : " + ex.Message); } } } }