Exemplo n.º 1
0
        private EntityScreen UpdateEntityScreens(OperationRequest <Entity> value)
        {
            var entityScreens =
                _applicationState.IsLocked ?
                _applicationState.GetTicketEntityScreens().ToList() :
                _applicationState.GetEntityScreens().ToList();

            if (!entityScreens.Any())
            {
                return(null);
            }
            _entityScreens         = entityScreens.OrderBy(x => x.SortOrder).ToList();
            _entitySwitcherButtons = null;
            var selectedScreen = _applicationState.SelectedEntityScreen;

            if (value != null && value.SelectedItem != null && _applicationState.CurrentDepartment != null)
            {
                if (_applicationState.IsLocked || _applicationState.CurrentDepartment.TicketCreationMethod == 1)
                {
                    _entityScreens = _entityScreens.Where(x => x.EntityTypeId == value.SelectedItem.EntityTypeId).OrderBy(x => x.SortOrder);
                }
                if (!_entityScreens.Any())
                {
                    return(entityScreens.ElementAt(0));
                }
                if (selectedScreen == null || selectedScreen.EntityTypeId != value.SelectedItem.EntityTypeId)
                {
                    selectedScreen = null;
                    if (!string.IsNullOrEmpty(value.Data))
                    {
                        selectedScreen = _entityScreens.Where(x => x.DisplayMode == 1).FirstOrDefault(x => x.EntityTypeId == value.SelectedItem.EntityTypeId);
                    }
                    if (selectedScreen == null)
                    {
                        selectedScreen = _entityScreens.FirstOrDefault(x => x.EntityTypeId == value.SelectedItem.EntityTypeId);
                    }
                }
                if (selectedScreen == null)
                {
                    selectedScreen = _entityScreens.ElementAt(0);
                }
            }
            return(selectedScreen ?? EntityScreens.ElementAt(0));
        }