public ActionResult FillIn(int id, bool embed = false) { using (var formManager = new FormAccessManager(GetLoginUser())) { TemplateViewModel model = null; var template = formManager.FindTemplate(id); if (template != null) { model = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT); if (!model.IsPublic && !IsUserAuthenticated()) { return(RedirectToError("Unauthorized access")); } model.Embed = embed; } else { return(RedirectToError("invalid id")); } return(View(model)); } }
//public FileStreamResult GetFileFromDisk(int valueId) //{ // FileValueObject obj = _formRepo.GetFileFieldValue(valueId); // if (obj != null) // { // if (obj.IsSavedInCloud) // { // } // else // { // var filePath = Server.MapPath(obj.SavePath.ConcatWith("/", obj.SaveName)); // var stream = UtilityHelper.ReadFile(filePath); // return File(stream, System.Net.Mime.MediaTypeNames.Application.Octet, obj.FileName); // } // } // throw new Exception("File Not Found"); //} public ActionResult ViewSaveForm(int id, string entryId, bool embed = false) { using (var formManager = new FormAccessManager(GetLoginUser())) { TemplateViewModel model = null; var template = formManager.FindLatestTemplate(id); if (template != null) { model = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT); model.Embed = embed; } else { return(RedirectToError("invalid id")); } foreach (var field in model.Fields) { field.EntryId = entryId; } return(View("FillIn", model)); } }
public void SetupTest() { var connection = DbConnectionFactory.CreateTransient(); _context = new PHSContext(connection); _unitOfWork = new MockUnitOfWork(_context); _formManager = new MockFormManager(_unitOfWork); _target = new MockPublicFormManager(_unitOfWork); }
public void CleanupTest() { // dispose of the database and connection _context.Dispose(); _unitOfWork.Dispose(); _formManager.Dispose(); _target.Dispose(); _unitOfWork = null; _context = null; _formManager = null; _target = null; }
public ActionResult SubmitConfirmation(int id, bool?embed) { using (var formManager = new FormAccessManager(GetLoginUser())) { var template = formManager.FindTemplate(id); if (template != null) { var templateView = TemplateViewModel.CreateFromObject(template); templateView.Embed = embed ?? embed.Value; TempData["success"] = templateView.ConfirmationMessage; return(View(templateView)); } return(RedirectToError("invalid id")); } }
//[SSl] public ActionResult PublicFillIn(string slug, bool embed = false) { using (var formManager = new FormAccessManager(GetLoginUser())) { var template = formManager.FindPublicTemplate(slug); if (template != null) { TemplateViewModel model = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT); model.Embed = embed; return(View(model)); } else { throw new HttpException(404, "No public Form found"); } } }
public ActionResult FillIn(IDictionary <string, string> SubmitFields, TemplateViewModel model, FormCollection formCollection) { InsertValuesIntoTempData(SubmitFields, formCollection); using (var formManager = new FormAccessManager(GetLoginUser())) { var template = formManager.FindTemplate(model.TemplateID.Value); var templateView = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT); string result = formManager.FillIn(SubmitFields, model, formCollection); if (result.Equals("success")) { //send notification if (!templateView.NotificationEmail.IsNullOrEmpty() && WebConfig.Get <bool>("enablenotifications", true)) { var notificationView = new NotificationEmailViewModel(); notificationView.FormName = templateView.Title; notificationView.Email = templateView.NotificationEmail; //TODO if need to use this, need to retrieve the entries //notificationView.Entries = ??; NotifyViaEmail(notificationView); } RemoveValuesFromTempData(formCollection); TempData["success"] = templateView.ConfirmationMessage; return(RedirectToRoute("form-submitconfirmation", new { id = template.TemplateID, embed = model.Embed })); } else { TempData["error"] = result; return(View("FillIn", templateView)); } } }
public ActionResult PreRegistration() { using (var formManager = new FormAccessManager(GetLoginUser())) { TemplateViewModel model = null; var template = formManager.FindPreRegistrationForm(); if (template != null) { model = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT); } else { throw new HttpException(404, "No Pre Registration Form found"); } return(View("PreRegistration", model)); } }