Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateSystemUser(SystemUsersViewModel model)
        {
            var user = await _userManager.GetUserAsync(User);

            var branchStaff = await _systemAdminService.GetBranchStaff(string.Empty);

            if (!ModelState.IsValid)
            {
                ViewData["Branches"] = new SelectList(_setupService.GetBranchNames(user.UserName));
                ViewData["Roles"]    = new SelectList(_roleManager.Roles);
                ViewData["Staff"]    = new SelectList(branchStaff);
                return(View(model));
            }

            model.ActionBy = user.UserName;
            Result         = await _systemAdminService.UpdateSystemUserAsync(model);

            if (Result == true)
            {
                StatusMessage = _config.GetSection("Messages")["Success"];
                return(RedirectToAction(nameof(SystemUsersListing)));
            }

            model = new SystemUsersViewModel {
                StatusMessage = "Error: Unable to update user account"
            };
            ViewData["Branches"] = new SelectList(_setupService.GetBranchNames(user.UserName));
            ViewData["Roles"]    = new SelectList(_roleManager.Roles);
            ViewData["Staff"]    = new SelectList(branchStaff);

            return(View(model));
        }