public ActionResult SubmitAProject(SubmitAProjectView model) { try { Configuration configurations = Configuration.Create(Db); EmailMssg mssg = new EmailMssg(); mssg.IsHtml = true; mssg.Receivers = new List <string>() { configurations.ContactFormEmail }; mssg.SenderAddress = "*****@*****.**"; mssg.Subject = "Contact request from " + model.FullName; mssg.TemplateModel = model; mssg.TemplateString = System.IO.File.ReadAllText(Server.MapPath("~/Templates/SubmitAProject.html")); EmailSender.Send(configurations, mssg); TempData["success"] = "Your project was successfully submitted"; } catch (Exception ex) { TempData["error"] = "Error while sending email: " + ex.ToString(); } return(View()); }
public ActionResult ExpressInterest(ExpressInterestViewModel viewModel) { try { InterestedUsers_Projects user2Project = new InterestedUsers_Projects() { ProjectId = viewModel.ProjectId, UserEmail = viewModel.Email, UserName = viewModel.User }; Db.InterestedUsers_Projects.Add(user2Project); int written = Db.SaveChanges(); try { Configuration configurations = Configuration.Create(Db); EmailMssg mssg = new EmailMssg(); mssg.IsHtml = true; mssg.Receivers = new List <string>() { configurations.ContactFormEmail }; mssg.SenderAddress = configurations.ftpConfig.Login; mssg.Subject = "User " + viewModel.User + " expressed interest in project "; mssg.TemplateModel = new ExpressInterestEmailModel() { ProjectName = viewModel.ProjectName, UserComment = viewModel.WhyInterested, UserEmail = viewModel.Email, UserName = viewModel.User }; mssg.TemplateString = System.IO.File.ReadAllText(Server.MapPath("~/Templates/InterestedInProject.html")); EmailSender.Send(configurations, mssg); } catch (Exception ex) { string error = "Error while sending approvment email" + ex.ToString(); TempData["error"] = error; return(RedirectToAction("Details", new { id = viewModel.ProjectId })); } return(new JsonResult() { Data = new { success = true } }); } catch (Exception ex) { TempData["error"] = "Error while expressing interest" + ex.ToString(); return(RedirectToAction("Details", new { id = viewModel.ProjectId })); } }
public ActionResult ApproveProject(ApproveViewModel model) { Project project = Db.Project.Find(model.ProjectId); project.IsApproved = true; try { project.Comment = model.Comment; Db.SaveChanges(); TempData["success"] = "Project " + project.Title + " was approved"; } catch (Exception ex) { TempData["error"] = "Error while approving report: " + ex.InnerException.ToString(); } try { string approvedBy = User.Identity.Name; string receiver = project.AddedByEmail; Configuration configurations = Configuration.Create(Db); EmailMssg mssg = new EmailMssg(); mssg.IsHtml = true; mssg.Receivers = new List <string>() { receiver }; mssg.SenderAddress = "*****@*****.**"; mssg.Subject = "Your project " + project.Title + " has been approved"; mssg.TemplateModel = new ApproveRejectModel() { Comment = model.Comment, ActionBy = approvedBy, ProjectName = project.Title }; mssg.TemplateString = System.IO.File.ReadAllText(Server.MapPath("~/Templates/ProjectApproved.html")); EmailSender.Send(configurations, mssg); } catch (Exception ex) { TempData["error"] = "Error while sending approvment email" + ex.ToString(); } return(RedirectToAction("Index")); }