public ActionResult FormDone(string formHash) { // whole form gets posted but we just want the instance code //string instanceCode = Request.Form[" Survey survey = m_db.Surveys.FirstOrDefault(s => s.FormHash == formHash); if (survey == null) throw new ApplicationException(string.Format("Could not find Survey with formHash {0}", formHash)); // if its a get, return a view now string httpVerb = HttpContext.Request.HttpMethod.ToUpper(); if (httpVerb == "GET") return View("FormDoneGet"); string instanceCode = Request.Form[survey.InstanceCodeFieldID]; if (string.IsNullOrEmpty(instanceCode)) throw new ApplicationException(string.Format("Webhook received empty {0} value for survey {1}", survey.InstanceCodeFieldID, survey.FormHash)); Filling filling = m_db.Fillings.FirstOrDefault(f => f.InstanceCode == instanceCode); if (filling == null) throw new ApplicationException(string.Format("Could not find Filling with instanceCode {0} for survey {1}", instanceCode, formHash)); var codeGen = new CodeGenerator(); filling.PavlovCode = codeGen.MakePavlovCode(); m_db.MarkModified(filling); m_db.SaveChanges(); return View(); }
public void MakePavlovCode_Varies() { var cg1 = new CodeGenerator(); var pavlov1 = cg1.MakePavlovCode(); var cg2 = new CodeGenerator(); var pavlov2 = cg2.MakePavlovCode(); Assert.IsNotNull(pavlov1); Assert.IsNotNull(pavlov2); Assert.AreEqual(6, pavlov1.Length); Assert.AreNotEqual(pavlov2, pavlov1, "generated strings should be different"); }