public ActionResult Upload(JobApplicationModel model) { if (ModelState.IsValid) { var mapped = JobApplicationMapper.Map(model); var result = _submitter.Submit(mapped); if (result == SubmissionErrors.InvalidExtension) ModelState.AddModelError("CVFile", "Invalid Extension for CV"); if (result == SubmissionErrors.MissingCV) ModelState.AddModelError("CVFile", "Empty CV"); if (result == SubmissionErrors.None) return RedirectToAction("Success"); } return View(model); }
public static JobApplication Map(JobApplicationModel model) { var result = new JobApplication() { Cover = model.Cover, Email = model.Email, Name = model.Name }; if (model.CVFile != null) { result.FileName = model.CVFile.FileName; using (var ms = new MemoryStream()) { model.CVFile.InputStream.CopyTo(ms); result.CV = ms.ToArray(); } } return result; }