Example #1
0
        public bool CreateSponsor(SponsorCreateView model)
        {
            var entity =
                new Sponsor()
            {
                BackGroundCheck = model.BackGroundCheck,
                FirstName       = model.FirstName,
                LastName        = model.LastName
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Sponsors.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #2
0
        public ActionResult Create(SponsorCreateView model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateSponsorService(_userId);

            if (service.CreateSponsor(model))
            {
                // ViewBag.SaveResult = "Your sponsor was created";
                TempData["SaveResult"] = "Your sponsor was created";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Sponsor could not be created");

            return(View());
        }