public ActionResult Index(ContactMessage contact_message) { if(ModelState.IsValid) { int id = contactService.AddContactMessage(contact_message); if (id > 0) { // Send Email UserMailer mailer = new UserMailer(); // Attempt to send the email try { string conctUs_email = ConfigurationManager.AppSettings["ContactUsEmail"]; mailer.ContactUs(conctUs_email, contact_message).Send(); } catch (Exception e) { LogService log_service = new LogService(DBContext); string message = e.Message; message += " " + e.StackTrace; if(e.InnerException != null) { message += e.InnerException.Message + e.InnerException.StackTrace; if (e.InnerException.InnerException != null) { message += e.InnerException.InnerException.Message + e.InnerException.InnerException.StackTrace; } } log_service.AddLog(new Log() { Message = message }); } TempData["success"] = true; return RedirectToAction("Index"); } else { TempData["success"] = false; return View(contact_message); } } else return View(contact_message); }
public ActionResult Apply(VacancyApplication vacancyApplication, int id, IEnumerable<HttpPostedFileBase> resume) { Vacancy vacancy = vacancyService.GetVacancy(id); if (vacancy == null) return RedirectToAction("Index"); if (vacancy.DeadLine.CompareTo(DateTime.Now) < 0) return RedirectToAction("Index"); if (ModelState.IsValid) { int new_id = vacancyService.AppplyToVacancy(id,vacancyApplication,resume); if (new_id > 0) { VacancyApplication vacApp = vacancyService.GetVacancyApplicationById(new_id); // Send Email UserMailer mailer = new UserMailer(); // Attempt to send the email try { string join_email = ConfigurationManager.AppSettings["JoinLogiEmail"]; mailer.JoinLogi(join_email, vacancy, vacApp).Send(); } catch (Exception e) { } TempData["Success"] = true; return Redirect(Url.RouteUrl(new { controller = "JoinLOGI", action = "Apply", id = id }) + "#thankyou"); //return RedirectToAction("Apply", new {id = id }); } else TempData["Success"] = false; } ViewBag.Vacancy = vacancy; return View(vacancyApplication); }
public ActionResult Expert(Expert expert, IEnumerable<HttpPostedFileBase> resume) { if (ModelState.IsValid) { int new_id = vacancyService.AppplyAsExpert(expert, resume); if (new_id > 0) { // Send Email UserMailer mailer = new UserMailer(); // Attempt to send the email try { string join_email = ConfigurationManager.AppSettings["JoinLogiEmail"]; mailer.JoinLogiAsExpert(join_email, expert).Send(); } catch (Exception e) { } TempData["Success"] = true; return Redirect(Url.RouteUrl(new { controller = "JoinLOGI", action = "Expert" }) + "#thankyou"); } else TempData["Success"] = false; } return View(expert); }