public ActionResult Create(ProspectCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateProspectService();

            if (service.CreateProspect(model))
            {
                TempData["SaveResult"] = "The prospect was added successfully.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "There was an issue adding the prospect.");

            return(View(model));
        }
Exemplo n.º 2
0
        // CREATE
        public bool CreateProspect(ProspectCreate model)
        {
            var entity =
                new Prospect()
            {
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Position  = model.Position,
                School    = model.School,
                SchoolID  = model.SchoolID,
                Report    = model.Report,
                Grade     = model.Grade,
                BigBoard  = model.BigBoard
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Prospects.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }