public virtual MvcMailMessage JoinLogiAsExpert(string to_email, Expert expert) { MasterName = "_EmailLayout"; ViewBag.expert = expert; string from_email = ConfigurationManager.AppSettings["FromEmail"]; return Populate(x => { x.Subject = expert.FullName + " Wants to join LOGI as an expert."; x.ViewName = "JoinLogiAsExpert"; x.ReplyToList.Add(expert.Email); x.To.Add(to_email); x.From = new MailAddress(from_email); }); }
public int AppplyAsExpert(Expert expert, IEnumerable<HttpPostedFileBase> resume = null) { expert.ApplyDate = DateTime.Now; DbContext.Experts.Add(expert); try { DbContext.SaveChanges(); if (resume != null && resume.Where(f => f != null).Count() > 0) { FilesService fs = new FilesService(); string file_url = fs.SaveFiles(resume); expert.ResumeURL = file_url; } DbContext.SaveChanges(); return expert.ID; } catch (Exception ex) { return -1; } }
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); }