Exemplo n.º 1
0
        public void AddUser([FromServices] AccountService service, [FromBody] AccountUserDto dto)
        {
            if (string.IsNullOrWhiteSpace(dto.Account))
            {
                throw new LogicException("帐号为空");
            }
            if (string.IsNullOrWhiteSpace(dto.Name))
            {
                throw new LogicException("名稱为空");
            }
            if (string.IsNullOrWhiteSpace(dto.PassWord))
            {
                throw new LogicException("密碼为空");
            }
            if (string.IsNullOrWhiteSpace(dto.ComfirmPassword))
            {
                throw new LogicException("确认密碼为空");
            }
            if (dto.PassWord != dto.ComfirmPassword)
            {
                throw new LogicException("两次密碼不一致");
            }
            var entity = dto.ProjectedAs <AccountUser>();

            service.AddUser(entity);
        }
Exemplo n.º 2
0
        public IDataResult <AccountUserDto> GetAccountUserInfo(string email)
        {
            User           user           = GetByEmail(email);
            AccountUserDto accountUserDto = _mapper.Map <AccountUserDto>(user);

            return(new SuccessDataResult <AccountUserDto>(accountUserDto));
        }
        public async Task <bool> EditAsync(AccountUserDto accountUser)
        {
            var user = await DBContext.Users.FirstOrDefaultAsync(x => x.Id == accountUser.Id);

            user.Name    = accountUser.Name;
            user.Phone   = accountUser.Phone;
            user.Address = accountUser.Address;
            if (!string.IsNullOrWhiteSpace(accountUser.Password))
            {
                var account = await DBContext.Accounts.FirstOrDefaultAsync(x => x.Email == accountUser.Email);

                account.Password = accountUser.Password;
            }
            return(await DBContext.SaveChangesAsync() > 0);
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Edit(AccountUserDto userDto)
        {
            if (!string.IsNullOrWhiteSpace(userDto.NewPassword))
            {
                userDto.Password = PasswordMd5.HashPassword(userDto.NewPassword);
            }
            bool result = await userDAO.EditAsync(userDto);

            if (result)
            {
                TempData["EditAccount"] = "Cập nhật thông tin thành công!";
            }
            else
            {
                TempData["EditAccount"] = "Đã hủy cập nhật thông tin!";
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 5
0
        public ActionResult Edit()
        {
            var account = (Account)Session[Constant.UserCustomerSession];

            if (account == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            AccountUserDto user = new AccountUserDto
            {
                Address = account.User.Address,
                Email   = account.Email,
                Name    = account.User.Name,
                Phone   = account.User.Phone,
                Id      = account.UserId
            };

            return(View(user));
        }
Exemplo n.º 6
0
        public void EditUser([FromServices] AccountService service, [FromBody] AccountUserDto dto)
        {
            var entity = dto.ProjectedAs <AccountUser>();

            service.EditUser(entity);
        }