Example #1
0
        public IHttpActionResult Post(RepCreate rep)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!repService.CreateLead(rep))
            {
                return(InternalServerError());
            }

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


            var service = new RepService();

            service.CreateRep(model);

            return(RedirectToAction("Index"));
        }
Example #3
0
        public bool CreateLead(RepCreate model)
        {
            var entity =
                new Rep()
            {
                Name  = model.Name,
                Email = model.Email,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Reps.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #4
0
        public bool CreateReps(RepCreate model)
        {
            var entity =
                new Rep()
            {
                RepId      = model.RepId,
                RepName    = model.RepName,
                Position   = model.Position,
                CreatedUtc = model.CreatedUtc
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Reps.Add(entity);

                return(ctx.SaveChanges() == 1);
            }
        }
Example #5
0
        public ActionResult Create(RepCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateRepService();

            if (service.CreateReps(model))
            {
                TempData["SaveResult"] = "Your Rep was created.";
                return(RedirectToAction("Index"));
            }
            ;

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

            return(View(model));
        }