Exemplo n.º 1
0
        public ActionResult Edit(int Id)
        {
            User users = UserRepository.GetById(Id);

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

            return View(input);
        }
Exemplo n.º 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}
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 private void UpdateUserFromInput(UserInput input)
 {
     User user =
         UserRepository.GetByUsername(input.Username);
     user.FirstName = input.FirstName;
     user.LastName = input.LastName;
     UserRepository.Save(user);
 }