Example #1
0
        public async Task Update(FullDataUserAccountDTO userAccount)
        {
            var result = GetById(userAccount.Id);

            result.Account.Password = userAccount.Password;

            _userRepository.Update(result);

            await _userRepository.UnitOfWork.SaveChangesAsync().ConfigureAwait(false);
        }
        public async Task <IActionResult> ChangePassword(FullDataUserAccountDTO userAccount)
        {
            if (userAccount == null)
            {
                return(RedirectToAction(nameof(Error)));
            }

            await _userService.Update(userAccount);

            return(RedirectToAction(nameof(Index)));
        }
 public static User ToUser(this FullDataUserAccountDTO userAccount)
 {
     return(new User()
     {
         Id = new Guid(),
         Name = userAccount.Name,
         DisplayName = string.Concat(userAccount.Name.Split(" ").FirstOrDefault(), " ", userAccount.Name.Split(" ").LastOrDefault()),
         Status = userAccount.Status,
         Active = userAccount.Active,
         Account = new Account()
         {
             Id = new Guid(),
             UserName = userAccount.UserName,
             Password = userAccount.Password
         }
     });
 }
        public async Task <IActionResult> Create(FullDataUserAccountDTO userAccount)
        {
            if (userAccount == null)
            {
                return(RedirectToAction(nameof(Error)));
            }

            try
            {
                await _userService.Create(userAccount.ToUser());

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e)
            {
                ViewData["UserExist"] = "User Exist!";
                return(View());
            }
        }