Ejemplo n.º 1
0
 public UserDTO ToDTO(User model)
 {
     return new UserDTO
                {
                     Id = model.Id,
                     Username = model.Username,
                     Password = model.Password,
                     Name = model.Name,
                     Role = model.Role,
                     Disabled = model.Disabled,
                     MustChangePassword = model.MustChangePassword
                };
 }
Ejemplo n.º 2
0
        public IEnumerable<MenuItem> GetMenuItemsForUser(User user)
        {
            var result = new List<MenuItem>();

            var allMenuItems = _menuRepository.GetAllItems();
            var allMenuAccessGroups = _accessGroupRepository.GetAll();

            foreach (var menuItem in allMenuItems)
            {
                var item = menuItem;
                if (item != null)
                {
                    var accessGroup = _accessGroupMapper.ToViewModel(allMenuAccessGroups.Where(x => x.Name == item.AccessGroup).FirstOrDefault());
                    if (accessGroup.RolesThatHaveAccess.Contains(user.Role))
                        result.Add(_menuItemModelMapper.FromDTO(item));
                }
            }
            return result.OrderBy(x => x.SortOrder);
        }