public ActionResult Create(Postulation postulation, HttpPostedFileBase curriculumFile)
        {
            JobSearch jobSearch = null;
            try
            {
                jobSearch = RavenSession.Load<JobSearch>(postulation.JobSearchId);
            }
            catch (Exception ex)
            {
                log.ErrorException("Error loading job search", ex);
                return InternalError();
            }

            if (jobSearch == null || !jobSearch.IsPublic)
                return NotFoundOrNotAvailable();

            if (curriculumFile == null)
                ModelState.AddModelError("curriculumFile", "Requerido");

            if (ModelState.IsValid)
            {
                try
                {
                    postulation.Curriculum = SaveTemporalFile(curriculumFile);
                }
                catch (Exception e)
                {
                    log.ErrorException("Error uploading file", e);
                    log.Dump(LogLevel.Error, postulation);
                    return InternalError();
                }

                try
                {
                    GenerateApplicant(postulation);
                    DeleteTemporalAttachment(postulation.Curriculum);

                    return RedirectToAction("Thanks", "Postulations");
                }
                catch (Exception e)
                {
                    log.ErrorException("Unexpected error creating postulations", e);
                    log.Dump(LogLevel.Error, postulation);
                    return InternalError();
                }
            }

            PrepareJobSearchView(jobSearch);
            return View();
        }
        private void GenerateApplicant(Postulation postulation)
        {
            //TODO: move it to an Action
            var applicant = new Applicant()
            {
                JobSearchId = postulation.JobSearchId,
                Email = postulation.Email,
                FirstName = postulation.FirstName,
                LastName = postulation.LastName
            };
            RavenSession.Store(applicant);

            applicant.Notes = new List<ApplicantNote>();

            if (postulation.Curriculum != null)
            {
                var curriculum = GenerateAttachment(applicant, postulation.Curriculum);
                applicant.AddGeneralNote("Currículum", curriculum);
            }

            if (!string.IsNullOrEmpty(postulation.Comment))
            {
                applicant.AddGeneralNote("Nota de postulación:\n\n" + postulation.Comment);
            }

            //TODO change this when links are in place
            if (!string.IsNullOrEmpty(postulation.LinkedInUrl))
            {
                applicant.AddGeneralNote("Perfil de LinkedIn: " + postulation.LinkedInUrl);
            }
        }
        private void GenerateApplicant(Postulation postulation)
        {
            //TODO: move it to an Action
            var applicant = new Applicant()
            {
                JobSearchId = postulation.JobSearchId,
                Email = postulation.Email,
                FirstName = postulation.FirstName,
                LastName = postulation.LastName,
                TechnicalSkills = postulation.TechnicalSkills,
                LinkedInLink = postulation.LinkedInUrl
            };
            RavenSession.Store(applicant);

            applicant.Notes = new List<NoteWithAttachment>();

            if (postulation.Curriculum != null)
            {
                var curriculum = GenerateAttachment(applicant, postulation.Curriculum);
                applicant.AddGeneralNote("Currículum", curriculum);
            }

            if (!string.IsNullOrEmpty(postulation.Comment))
            {
                applicant.AddGeneralNote("Nota de postulación:\n\n" + postulation.Comment);
            }
        }