public ActionResult Index(ContactModel contactModel) { RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper(); if (String.IsNullOrEmpty(recaptchaHelper.Response)) { ModelState.AddModelError("", "Captcha answer cannot be empty."); return(Index()); } if (ModelState.IsValid) { contactModel.Brand = this.CurrentBrand; var ok = ContactManager.Create(contactModel); if (ok) { return(RedirectToAction("ThankYou")); } else { return(RedirectToAction("Index")); } } else { return(RedirectToAction("Index")); } }
public void CreateTest() { const string TEST_MESSAGE = "contact"; ContactDto result = _contactManager.Create(TEST_MESSAGE); Assert.AreEqual(0, result.Id); Assert.AreEqual(TEST_MESSAGE, result.Value); }
// POST public IHttpActionResult Post(Contact contact) { try { var mng = new ContactManager(); mng.Create(contact); apiResp = new ApiResponse(); apiResp.Message = "Action was executed"; return(Ok(apiResp)); } catch (BusinessException bex) { return(InternalServerError(new Exception(bex.ExceptionID + "-" + bex.AppMessage.Message))); } }