Esempio n. 1
0
        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);
        }
Esempio n. 2
0
		public virtual MvcMailMessage JoinLogi(string to_email, Vacancy vacancy, VacancyApplication application)
		{
            MasterName = "_EmailLayout";
            ViewBag.vacancy = vacancy;
            ViewBag.vacancyApplication = application;

            string from_email = ConfigurationManager.AppSettings["FromEmail"];

			return Populate(x =>
			{
                x.Subject = application.FullName + " Wants to join LOGI team.";
                x.ViewName = "JoinLogi";
                x.ReplyToList.Add(application.Email);
                x.To.Add(to_email);
                x.From = new MailAddress(from_email);
                
			});
		}
Esempio n. 3
0
        public int AppplyToVacancy(int vacancy_id, VacancyApplication application, IEnumerable<HttpPostedFileBase> resume = null)
        {
            Vacancy vacancy = DbContext.Vacancies.Where(v => v.ID == vacancy_id).FirstOrDefault();

            if (vacancy == null)
                return -1;

            if (vacancy.VacancyApplications == null)
                vacancy.VacancyApplications = new List<VacancyApplication>();

            application.ApplyDate = DateTime.Now;

            vacancy.VacancyApplications.Add(application);
            try
            {
                DbContext.SaveChanges();

                if (resume != null && resume.Where(f => f != null).Count() > 0)
                {
                    FilesService fs = new FilesService();

                    string file_url = fs.SaveFiles(resume);
                    application.ResumeURL = file_url;
                }
                DbContext.SaveChanges();

                return application.ID;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }