public HttpResponseMessage Post(ProposalAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); response.Item = ProposalService.Post(model); ProposalSendRequest sendRequest = new ProposalSendRequest(); sendRequest.FirstName = model.FirstName; sendRequest.LastName = model.LastName; sendRequest.Email = model.Email; sendRequest.PhoneNumber = model.PhoneNumber; sendRequest.Deadline = model.Deadline; sendRequest.Budget = model.Budget; sendRequest.Company = model.Company; sendRequest.ProjectType = model.ProjectType; sendRequest.Description = model.Description; _emailService.SendProposalAdmin(sendRequest); ProposalSendRequest userRequest = new ProposalSendRequest(); userRequest.FirstName = model.FirstName; userRequest.LastName = model.LastName; userRequest.Email = model.Email; _emailService.SendProposalUser(userRequest); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public async Task <bool> SendProposalUser(ProposalSendRequest model) { string name = "Operation Code"; string toName = model.FirstName + " " + model.LastName; string toAddress = model.Email; string path = HttpContext.Current.Server.MapPath("~/HTML_Templates/ProposalUserResponseEmail.html"); string emailBody = System.IO.File.ReadAllText(path); string finalEmail = emailBody.Replace("{{firstName}}", model.FirstName); string subject = "Thank you for contacting Deploy!"; string firstName = model.FirstName; string lastName = model.LastName; string email = model.Email; string messageText = "Thank you for contacting Deploy!"; string messageHtml = finalEmail; return(await Send("*****@*****.**", toName, name, toAddress, subject, messageText, messageHtml)); }
public async Task <bool> SendProposalAdmin(ProposalSendRequest model) { string name = "Operation Code"; string toName = "OpCode Admin"; string toAddress = System.Web.Configuration.WebConfigurationManager.AppSettings["SiteAdminEmailAddress"]; string subject = "New Proposal From Deploy Site User"; string path = HttpContext.Current.Server.MapPath("~/HTML_Templates/ProposalAdminEmail.html"); string emailBody = System.IO.File.ReadAllText(path); string budgetString; if (model.Budget.HasValue) { budgetString = model.Budget.Value.ToString(); } else { budgetString = "tbd"; } string finalEmail = emailBody.Replace("{{firstName}}", model.FirstName) .Replace("{{lastName}}", model.LastName) .Replace("{{email}}", model.Email) .Replace("{{phoneNumber}}", model.PhoneNumber) .Replace("{{deadline}}", model.Deadline) .Replace("{{budget}}", budgetString) .Replace("{{company}}", model.Company) .Replace("{{projectType}}", model.ProjectType) .Replace("{{description}}", model.Description) .Replace("{{siteURL}}", SiteConfig.BaseUrl); string messageText = "New Proposal From Deploy Site User"; string messageHtml = finalEmail; return(await Send("*****@*****.**", toName, name, toAddress, subject, messageText, messageHtml)); }