public virtual ActionResult TestFormSave(TestFormModel model) { // classical ModelState.IsValid should be handled by [FormValidator] attribute already // calling dummy BL method to mimic data persistence to somewhere this.businessLogic.SaveTestForm(model); // Fulfilling PRG pattern - here we passing fake ID to initiate GET View hydratation return this.RedirectToAction(MVC.Sandbox.TestForm()); }
/// <summary> /// Saves the single column layout model to DB or sends to Service /// Note: This is fake for DEMO purposes /// </summary> /// <param name="model">The model from View.</param> /// <returns>Saved object ID (also fake)</returns> public int SaveTestForm(TestFormModel model) { // here we would call some external persistence object method to save model data // and return this object ID (just in case, if it needs to be loaded by READ/GET screen) return 21; }
public virtual ActionResult ExceptionTestApp(TestFormModel model) { this.Logger.Info("There should be another Log record about purposely throwed Application exception"); throw new EserviceException("This is Dummy App exception throwed from Sandbox"); }
/// <summary> /// Gets the single column form model for view Display /// </summary> /// <param name="id">The identifier as if for DB ID.</param> public TestFormModel GetTestFormModel(int? id) { // var alphas = this.databaseHelper.Count<ApplicationUser>(t => t.UserName.StartsWith("A")); // var umas = this.umaData.Execute(s => s.GetCodeByLabel("RUSSIA")); var model = new TestFormModel(); model.CountryList = this.StateList; if (!id.HasValue) { // No ID - just empty model (as to create new object) // model.FirstField = "UMA WCF: " + umas.Code.Label + " = " + umas.Code.TextFinnish; return model; } // Assume we are calling here DB or service logic and getting object which map into model model.FirstField = "Dummy data from logic (faking DB/Svc load)"; model.RequiredField = "Something for your requirements"; model.ValidationField = "123, the validation"; return model; }