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")); }
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); } }
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); } }
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)); }