public bool ConsumerCreate(ConsumerCreate model) { var entity = new Consumer() { Name = model.Name, Email = model.Email, Address = model.Address, PhoneNumber = model.PhoneNumber, }; using (var ctx = new ApplicationDbContext()) { ctx.Consumers.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult ConsumerCreate(ConsumerCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new ConsumerService(); if (service.ConsumerCreate(model)) { TempData["SaveResult"] = "The Consumer was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "The Consumer could not be created."); return(View(model)); }