public ActionResult Create(RecruitmentInputModel model, HttpPostedFileBase image = null) { if (model != null && this.ModelState.IsValid) { if (image != null) { if (image.ContentLength <= 1000000) { var e = new Applicant() { biography = model.biography, birtdate = model.birtdate, email = model.email, firstName = model.firstName, lastName = model.lastName, phone = model.phone, city = model.city, country = model.country, position = model.position, postalCode = model.postalCode, streetAddress = model.streetAddress, photoMimeType = image.ContentType, photoData = new byte[image.ContentLength] }; image.InputStream.Read(e.photoData, 0, image.ContentLength); this.db.applicants.Add(e); this.db.SaveChanges(); try { SendMail("w").Wait(); } catch (Exception) { throw; } //return this.RedirectToAction("GetImage"); TempData["applyEmail"] = e.email; return(this.RedirectToAction("MessajeApplying")); } else { TempData["msj01"] = "The file size must be less than or equal to 1 mb"; return(this.RedirectToAction("Create", model)); } } } return(this.View(model)); }
public async Task <IActionResult> Create(RecruitmentInputModel model) { if (!ModelState.IsValid) { return(this.View()); } var id = await this.recruitmentService.AddAsync(model.Title, model.StartingAt, model.PitchId, this.User.GetId(), model.MaximumPlayers); return(this.RedirectToAction(nameof(Details), new { id })); }
// GET: Recruitment public ActionResult Create(RecruitmentInputModel model) { try { var positions = (from e in this.db.positions where e.noActive == false select new { id = e.id, name = e.name }).ToList() .Select(x => new Position() { id = x.id, name = x.name }); //var positions = this.db.positions //.Where(e => e.noActive == false) //.Select(e => new Position() //{ // id = e.id, // name = e.name, // noActive = e.noActive //}).ToList(); //IEnumerable<SelectListItem> lstPositions = new SelectList(positions, "id", "name"); //ViewData["lstPositions"] = lstPositions; var recruitment = new RecruitmentInputModel() { lstPositions = new SelectList(positions, "name", "name") }; if (model != null) { } return(View(recruitment)); } catch (Exception ex) { throw ex; } }