// // GET: AppUsers/Create // public IActionResult Create() // { // return View(); // } // // POST: AppUsers/Create // // To protect from overposting attacks, please enable the specific properties you want to bind to, for // // more details see http://go.microsoft.com/fwlink/?LinkId=317598. // [HttpPost] // [ValidateAntiForgeryToken] // public async Task<IActionResult> Create([Bind("FirstName,LastName,HiringDate,LeftJob,PhoneNr,Email,Id")] // AppUser appUser) // { // appUser.AppUserId = User.GetUserId(); // // // if (ModelState.IsValid) // { // _bll.AppUsers.Add(appUser); // await _bll.SaveChangesAsync(); // // return RedirectToAction(nameof(Index)); // } // // return View(appUser); // } // GET: AppUsers/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var appUser = await _bll.AppUsers.FindAsync(id); if (appUser == null) { return(NotFound()); } var vm = new Areas.Admin.ViewModels.AppUserCreateEditViewModel(); vm.AppUser = appUser; // vm.AppUserPositionSelectList = new SelectList( // await _bll.AppUsersPositions.AllAsync(), // nameof(BLL.App.DTO.AppUserPosition.Id), // nameof(BLL.App.DTO.AppUserPosition.AppUserPositionValue)); return(View(vm)); }
public async Task <IActionResult> Edit(int id, Areas.Admin.ViewModels.AppUserCreateEditViewModel vm) { if (id != vm.AppUser.Id) { return(NotFound()); } if (ModelState.IsValid) { _bll.AppUsers.Update(vm.AppUser); await _bll.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } // //TODO: not working // vm.AppUserPositionSelectList = new SelectList( // await _bll.AppUsersPositions.AllAsync(), // nameof(BLL.App.DTO.AppUserPosition.Id), // nameof(BLL.App.DTO.AppUserPosition.AppUserPositionValue)); return(View(vm)); }