public static IEnumerable<PrivacyFormData> ViewPrivacyForms(DateTime startDate, DateTime endDate) { string conString = ConfigurationManager.ConnectionStrings["mongoform.write"].ToString(); string collectionName = Constants.DataBaseConstants.CollectionNames.PRIVACYELECTIONS; PrivacyElectionForm pFormRepo = new PrivacyElectionForm (conString, collectionName); IMongoQuery startDatequery = Query<PrivacyFormData>.GTE(p => p.AuditInsertDateUTC, new BsonDateTime(startDate.ToUniversalTime())); IMongoQuery endDatequery = Query<PrivacyFormData>.LTE(p => p.AuditInsertDateUTC, new BsonDateTime(endDate.AddHours(23.59).ToUniversalTime())); return pFormRepo.Select(Query.And(startDatequery, endDatequery)); }
public ActionResult ProcessPrivacyForm(PrivacyForm model) { try { model.FormSubmitted = true; if (ModelState.IsValid) { //TODO -- simplify -- just use connection string in connection strings - and just have 1 constant for dbName and CollectionName string conString = ConfigurationManager.ConnectionStrings["mongoform.write"].ToString(); string collectionName = Constants.DataBaseConstants.CollectionNames.PRIVACYELECTIONS; PrivacyFormData formData = new PrivacyFormData(); formData.FirstName = model.FirstName; formData.LastName = model.LastName; formData.Address = model.Address; formData.City = model.City; formData.State = model.State; formData.ZipCode = model.ZipCode; formData.Phone = model.Phone; PrivacyElectionForm pFormRepo = new PrivacyElectionForm(conString, collectionName); pFormRepo.Insert(formData); //Need to clear form controls so loading model again model = defaultModel(); model.SaveSuccessful = true; model.FormSubmitted = true; return View("~/TechITPro/Views/Renderings/Sections/Components/PrivacyForm/PrivacyForm.cshtml", model); } else { //Set error when form is not submitted ModelState.AddModelError("", model.ErrorAlert); model.FormSubmitted = false; var combinedmodel = this.CombineModel(model); return View("~/TechITPro/Views/Renderings/Sections/Components/PrivacyForm/PrivacyForm.cshtml", combinedmodel); } } catch (Exception ex) { model.SaveSuccessful = false; Log.Error("Error Submitting Privacy Form" + ex.StackTrace, this); return View("~/TechITPro/Views/Renderings/Sections/Components/PrivacyForm/PrivacyForm.cshtml"); } }