public JsonResult ContactUs(Contact contact) { if (!ModelState.IsValid) { this.ControllerContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; return this.Json(contact, JsonRequestBehavior.AllowGet).AsCamelCaseResolverResult(); } this.contactService.AddContact(contact); bool hasSent = this.mailService.SendContactMail(contact); if (!hasSent) { this.ControllerContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; return this.Json(Messages.SendMailError, JsonRequestBehavior.AllowGet).AsCamelCaseResolverResult(); } return this.Json(contact, JsonRequestBehavior.AllowGet).AsCamelCaseResolverResult(); }
public void Setup() { this.mockRepository = new Mock<IContactRepository>(); this.contactService = new ContactService(this.mockRepository.Object); this.oneContact = this.OneContact(); }