public virtual string Validate(SetUp s) { value = s.Value; if (!s.Value.ToLower().Equals(value.ToLower())) return ValidatorContext.Validate(type).Validator(value, fieldName); else return value; }
public virtual SetUp AddInfo(SetUp s) { s.Name = fieldName; s.Description = description; s.Type = type; s.Value = value; return s; }
public override SetUp AddInfo(SetUp s) { try { throw new Exception("The strategy is unknown"); } catch { throw; } }
private void SetupSingle(string theName) { SetupContext setupContext = new SetupContext(repo, userName); ISetupStrategy strategy = setupContext.Create(theName); SetUp setupNew = new SetUp(); setupNew = strategy.AddInfo(setupNew); repo.Create(setupNew); repo.Save(); }
public ActionResult Edit([Bind(Include = "Id,Value")] SetupVM setUp) { if (ModelState.IsValid) { SetUp sDb = new SetUp(); try { sDb = repo.FindFor(setUp.Id); } catch (Exception e) { return RedirectToIndexActionErrorHelper("There was a problem. No record was found. ", e); } SetupContext setupContext = new SetupContext(repo, userName); ISetupStrategy setupStrategy = setupContext.Create(sDb.Name); sDb.Value = setUp.Value; try { sDb.Value = setupStrategy.Validate(sDb); repo.Update(sDb); repo.Save(); setupStrategy.Memory = setUp.Value; } catch(Exception e) { string m = MakeErrorMesage("Answer not saved.", e); ModelState.AddModelError("", m); setUp.Description = sDb.Description; setUp.Id = sDb.Id; setUp.Name = sDb.Name; setUp.Value = sDb.Value; return View(setUp); } } return RedirectToIndexActionHelper("Saved!"); }
//------------------------------------------------------------------------------------------------------------ // GET: SetUps/Edit/5 public ActionResult Edit(long? id) { SetUp setUp = new SetUp(); try { setUp = repo.FindFor(id); } catch(Exception e) { return RedirectToIndexActionErrorHelper("There was a problem. No record was found. ", e); } SetupVM setupVM = new SetupVM(); setupVM.Id = setUp.Id; setupVM.Description = setUp.Description; setupVM.Value = setUp.Value; if (setUp.Type==EnumTypes.EmailingMethod) { List<SelectListVM> emailOptions = new List<SelectListVM> { new SelectListVM { Id="sendgrid",Name="sendgrid"}, new SelectListVM {Id="smtp",Name="smtp"}, new SelectListVM {Id="test",Name=@"Create dir at c:\TestEmail"} }; ViewBag.Value = new SelectList(emailOptions, "Id", "Name", setupVM.Value); return View("EditWithDropDown", setupVM); } return View(setupVM); }
//------------------------------------------------------------------------------------------------------------ // GET: SetUps/Details/5 public ActionResult Details(long? id) { SetUp setUp= new SetUp(); try { setUp = repo.FindFor(id); return View(setUp); } catch(Exception e) { string message = e.Message; if (e.InnerException != null) message += " SYSTEM ERROR: " + e.InnerException.Message; return RedirectToIndexActionErrorHelper("There was a problem. No record was found. ", e); } }
public override SetUp AddInfo(SetUp s) { return base.AddInfo(s); }
protected void AddToSetup(SetUp s) { try { repo.Create(s); repo.Save(); } catch { } }