public void InsertOrUpdate(User user)
 {
     if (user.UserID == default(int)) {
         // New entity
         context.Users.Add(user);
     } else {
         // Existing entity
         context.Entry(user).State = EntityState.Modified;
     }
 }
        public ActionResult Edit(User user)
        {
            if (ModelState.IsValid) {
                userRepository.InsertOrUpdate(user);
                userRepository.Save();
                return RedirectToAction("Index", "FranchiseSet", new { id = user.FranchiseSetId } );
            } else {
				ViewBag.PossibleFranchiseSets = franchisesetRepository.All;
				return View();
			}
        }
        //
        // GET: /User/Create

        public PartialViewResult Create(int FranchiseSetId)
        {
			ViewBag.PossibleFranchiseSets = franchisesetRepository.All;
            var user = new User { FranchiseSetId = FranchiseSetId };
            return PartialView(user);
        }