public ActionResult Create(RecruitCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateRecruitService(); if (service.CreateRecruit(model)) { TempData["saveresults"] = "your recruit was added, hope you get him"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "there was an error with this prospect"); return(View(model)); }
public bool CreateRecruit(RecruitCreate model) { var entity = new Recruit() { FirstName = model.FirstName, LastName = model.LastName, School = model.School, GraduationDate = model.GraduationDate, StarRating = model.StarRating, Position = model.Position, Strengths = model.Strengths, Weaknesses = model.Weaknesses, IsOfferedScholarship = model.IsOfferedScholarship, Comments = model.Comments, SchoolId = model.SchoolId }; using (var ctx = new ApplicationDbContext()) { ctx.Recruits.Add(entity); return(ctx.SaveChanges() == 1); } }