/// <summary>
        /// 儲存更新帳號
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <ActionResult> Save(UserModel model)
        {
            _logger.Information($"UpdateAccount : { JsonConvert.SerializeObject(model)}");

            ResponseViewModel result = new ResponseViewModel();

            try
            {
                result = await _aspNetUsersService.UpdateUser(model);

                if (result.IsOk)
                {
                    TempData["SaveResult"] = result;
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                _logger.Information($"UpdateAccount exception: { JsonConvert.SerializeObject(ex)}");
                throw ex;
            }
            return(RedirectToAction("EditAccount", model));
        }
Esempio n. 2
0
        public ActionResult Edit(string id, IdentityUserViewModel editModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(editModel));
            }

            var contact = _aspNetUsersService.GetUser(id);

            if (contact != null)
            {
                var isAuthorized = true;
                if (!isAuthorized)
                {
                    return(View());
                }

                contact = _mapper.Map <AspNetUser>(editModel);
                bool result = _aspNetUsersService.UpdateUser(contact);
            }

            return(RedirectToAction("Index"));
        }