Exemple #1
0
        public UserInformationsDto GetById(Guid id)
        {
            var user = _repository.GetLastByFilter <User>(x => x.Id == id);

            var userDto = new UserInformationsDto
            {
                Email     = user.Email,
                FirstName = user.FirstName,
                LastName  = user.LastName,
                Username  = user.Username
            };

            return(userDto);
        }
Exemple #2
0
        public IActionResult Register([FromBody] UserDto userDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = _userLogic.Create(userDto, userDto.Password);

            var userInformationDto = new UserInformationsDto
            {
                Email     = user.Email,
                FirstName = user.FirstName,
                LastName  = user.LastName,
                Username  = user.Username
            };

            return(Ok(userInformationDto));
        }
Exemple #3
0
        IEnumerable <UserInformationsDto> IUserLogic.GetAll()
        {
            List <UserInformationsDto> usersDtos = new List <UserInformationsDto>();

            var users = this._repository.GetAll <User>();

            foreach (var user in users)
            {
                var userDto = new UserInformationsDto
                {
                    Email     = user.Email,
                    FirstName = user.FirstName,
                    LastName  = user.LastName,
                    Username  = user.Username
                };
                usersDtos.Add(userDto);
            }

            return(usersDtos);
        }