public ActionResult Send(SendRequestModel request) { var response = new SendResponseModel(); //try to send email and make appropriate json object if not. response.Errors.AddRange(SendMailService.SendMail(request)); if (!response.Errors.Any()) { response.Message = "Email sent successfully. We will respond ASAP!</p><br><p>You will be redirected to the home page shortly."; } return(Json(response)); //? Json(new { status = "success", Message = "<p>Email sent successfully. We will respond ASAP!</p><br><p>You will be redirected to the home page shortly.</p><br>" }) //: Json(new { status = "error", Message = "<p>Error sending email.</p><br><p> Please make sure your information is correct.</p>" }); }
private SendResponseModel SendSms(string json, Encoding encoding, string url) { var responseModel = new SendResponseModel(); try { int httpStatusCode; var responseJson = ExecuteRequest(encoding, json, url, out httpStatusCode); var responseObject = JsonConvert.DeserializeObject <SendResponseModel>(responseJson); responseObject.HttpStatusCode = httpStatusCode; return(responseObject); } catch (WebException we) { responseModel.Exception = we; responseModel.HttpStatusCode = ((HttpWebResponse)we.Response).GetHttpStatusCode(); } catch (Exception e) { responseModel.Exception = e; } return(responseModel); }