Exemple #1
0
 public ActionResult EditMoviegoer(int id, MoviegoerViewModel moviegoerViewModel)
 {
     try
     {
         MoviegoerAPI.Update(moviegoerViewModel.Moviegoer);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Exemple #2
0
        // GET: Admin/Edit/5
        public async Task <ActionResult> EditMoviegoer(int id)
        {
            List <Moviegoer> moviegoers = await MoviegoerAPI.GetAll();

            MoviegoerViewModel viewModel = new MoviegoerViewModel();

            viewModel.Moviegoer = moviegoers.Where(m => m.Id == id).First();
            List <KeyValuePair <string, string> > rolesList = _roleManager.Roles.Select(r => new KeyValuePair <string, string>(r.Id, r.Name)).ToList();

            viewModel.RoleManager = new Dictionary <string, string>();
            foreach (KeyValuePair <string, string> role in rolesList)
            {
                viewModel.RoleManager.Add(role.Key, role.Value);
            }
            return(View(viewModel));
        }