Example #1
0
        public List <ReadUserDTO> GetAllUsers()
        {
            List <ReadUserDTO> dtos;

            using (UnitOfWork unit = new UnitOfWork())
            {
                List <User> users = unit.UserRepository.GetAll();
                dtos = ReadUserDTO.FromEntityList(users);
            }
            return(dtos);
        }
        private void DeleteUserPermissionAction(object obj)
        {
            ReadUserDTO user = (ReadUserDTO)obj;

            if (user != null && user.Username != ActiveUser.Instance.LoggedUser.Username)
            {
                ReadUser u = Users.FirstOrDefault(x => x.username == user.Username);

                if (u != null)
                {
                    Users.Remove(u);
                }
            }
        }
Example #3
0
        public ReadUserDTO GetUser(string username)
        {
            ReadUserDTO userDTO = null;

            using (UnitOfWork unit = new UnitOfWork())
            {
                User u = unit.UserRepository.GetUserByUsername(username);

                if (u != null)
                {
                    userDTO = new ReadUserDTO(u);
                }
            }

            return(userDTO);
        }
        public IActionResult GetAll()
        {
            try
            {
                var users       = _repository.GetAll();
                var parsedUsers = new List <ReadUserDTO> {
                };

                foreach (User user in users)
                {
                    var parsedUser = new ReadUserDTO {
                        Id = user.Id, Name = user.Name
                    };

                    parsedUsers.Add(parsedUser);
                }

                return(Ok(new SuccessActionResult <IEnumerable <ReadUserDTO> >(parsedUsers)));
            }
            catch (Exception exception)
            {
                return(StatusCode(500, new ErrorActionResult(500, exception.Message)));
            }
        }