public ActionResult AddDealer() { SmartFarmingEntities db = new SmartFarmingEntities(); AddDealer model = new AddDealer() { Roles = db.Roles.ToList() }; return(View(model)); }
public ActionResult AddDealer(AddDealer model) { User usermodel = new User() { Name = model.Name, Email = model.Email, role_id = model.role_id }; using (SmartFarmingEntities dbcrop = new SmartFarmingEntities()) { dbcrop.Users.Add(usermodel); dbcrop.SaveChanges(); } ModelState.Clear(); ViewBag.SucessMessage = "Item Added Sucessful."; return(RedirectToAction("ManageDealer")); }