예제 #1
0
        public ActionResult Edit(int Id)
        {
            User users = UserRepository.GetById(Id);

            UserInput viewModel = new UserInput()
                                  	{
                                  		Username = users.Username
                                  	};
            return View(viewModel);
        }
예제 #2
0
        public ActionResult Edit(UserInput input)
        {
            if (ModelState.IsValid)
            {
                UpdateUserFromInput(input);
                TempData["message"] = "The user was updated";
                return RedirectToAction("index");
            }

            return View(input);
        }
예제 #3
0
        public ActionResult Edit(UserInput input)
        {
            if (ModelState.IsValid)
            {
                //do some work to update a User from the UserInput and persist the User to the database.
                return RedirectToAction("index"); //Successful Flow
                //Post Redirect Get
            }

            return new ViewResult(){
                ViewData = this.ViewData,
                TempData = this.TempData,
                ViewName = ""};// Failure Flow}
        }
예제 #4
0
        public ActionResult Edit(int Id)
        {
            User users = UserRepository.GetById(Id);

            var viewModel = new UserInput
                                {
                                    Username =
                                        users.Username,
                                    FirstName =
                                        users.FirstName,
                                    LastName =
                                        users.LastName,
                                };
            return View(viewModel);
        }
예제 #5
0
 private void UpdateUserFromInput(UserInput input)
 {
     User user =
         UserRepository.GetByUsername(input.Username);
     user.FirstName = input.FirstName;
     user.LastName = input.LastName;
     UserRepository.Save(user);
 }