private void FillFilters(bool filteredFilter)
        {
            if (!filteredFilter)
            {
                CompleteRequesterTeamList = new ObservableCollection <Team>(TeamList);
                CompleteRequestStateList  = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(5).Where(x => x.ID != 42 && x.ID != 25));
                CompleteRequestTypeList   = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(4));
                MyTeamMembersList         = new ObservableCollection <Student>(new StudentDAL().FindAll(x => x.TeamID == ContextStudent.ID));

                RequestProviderTeamList = new ObservableCollection <Team>(TeamList);
                RequestedStateList      = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(5));
                RequestedTypeList       = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(4));
                RequestedCreatorList    = new ObservableCollection <Student>(new StudentDAL().FindAll(x => x.TeamID == ContextStudent.ID));
            }
            CompleteRequestCreatorList = new ObservableCollection <Student>();
            RequestedAssigneeList      = new ObservableCollection <Student>();

            int?RequesterTeamFilterID = RequesterTeamFilter?.ID;

            if (RequesterTeamFilterID != null)
            {
                CompleteRequestCreatorList = new ObservableCollection <Student>(new StudentDAL().FindAll(x => x.TeamID == requesterTeamFilter.ID));
            }
            int?ProviderTeamFilterID = ProviderTeamFilter?.ID;

            if (ProviderTeamFilterID != null)
            {
                RequestedAssigneeList = new ObservableCollection <Student>(new StudentDAL().FindAll(x => x.TeamID == ProviderTeamFilter.ID));
            }
        }
        private void RequestApprove(object param)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("Jóváhagyás után az igénylés nem szerkeszthető a nyújtó csapat által! Folytatja?", "Megerősítés", MessageBoxButton.YesNo, MessageBoxImage.Question);
            ServiceRequest   requestToApprove = ServiceRequestDal.FindById(((ServiceRequest)((DataGrid)param).SelectedItem).ID);

            requestToApprove.RequestState = DictionaryDal.DictionaryListByType(5).First(x => x.ID == 24).ID;
            ServiceRequestDal.Update(requestToApprove);
            this.RequestedRequestsList = ReloadRequestedRequests();
            this.ProvidedRequestsList  = ReloadProvidedRequestsList();
        }
        private bool CanDeleteServiceRequest(object param)
        {
            if (((DataGrid)param).SelectedItem == null)
            {
                return(false);
            }
            ServiceRequest selectedServiceRequest = (ServiceRequest)((DataGrid)param).SelectedItem;
            int            NewID    = DictionaryDal.DictionaryListByType(5).Where(x => x.ID == 21).FirstOrDefault().ID;
            int            DeniedID = DictionaryDal.DictionaryListByType(5).Where(x => x.ID == 25).FirstOrDefault().ID;

            return(selectedServiceRequest.RequestState == NewID || selectedServiceRequest.RequestState == DeniedID);
        }
        public ServiceTableFieldViewModel(ServiceTableFieldWindow sourceWindow, ServiceTableField selectedServiceTableField)
        {
            this._contextDal  = new ServiceTableFieldDAL();
            this.SourceWindow = sourceWindow;
            this.SelectedServiceTableField = selectedServiceTableField;
            this.SaveCommand     = new RelayCommand(SaveServiceTableField, CanExecute);
            this.DictionaryDal   = new DictionaryDAL();
            this.ServiceTableDal = new ServiceTableDAL();
            this.TableFieldList  = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(3));
            ServiceTable st = ServiceTableDal.FindById((int)selectedServiceTableField.TableID);
            int          contextSessionGroupID = st.Team.SessionGroupID;

            this.TableList = new ObservableCollection <ServiceTable>(ServiceTableDal.FindAll(x => x.Team.SessionGroupID == contextSessionGroupID));
        }
        public ServiceRequestViewModel(int sessionGroupID, ServiceRequest selectedServiceRequest, ServiceRequestWindow sourceWindow, Student contextStudent, string semiReadOnly)
        {
            _contextDal            = new ServiceRequestDAL();
            this.DictionaryDal     = new DictionaryDAL();
            this.TeamDal           = new TeamDAL();
            this.ServiceStoreDal   = new ServiceStoreDAL();
            this.StudentDal        = new StudentDAL();
            this.RequestMessageDal = new RequestMessageDAL();

            this.SemiReadOnly           = semiReadOnly == "ServiceRequestsGrid";
            this.SourceWindow           = sourceWindow;
            this.SelectedServiceRequest = selectedServiceRequest;

            this.SelectedProviderTeamID       = SelectedServiceRequest.ProviderTeamID;
            this.SelectedServiceStore         = ServiceStoreDal.FindAll(x => x.ID == SelectedServiceRequest.ServiceID).FirstOrDefault();
            this.SelectedServiceRequestTypeID = SelectedServiceRequest.RequestType;


            this.AssigneeList = ReloadAssigneeList();

            RequestMessageList        = ReloadRequestMessageList();
            this.CreateRequestMessage = new RelayCommand(RequestMessageCreate, CanCreateRequestMessage);
            this.ContextStudent       = contextStudent;
            this.SaveCommand          = new RelayCommand(SaveRequest, CanSave);
            if (DictionaryDal.DictionaryListByType(5).Where(x => x.ID == 24).FirstOrDefault().ID == SelectedServiceRequest.RequestState)
            {
                this.RequestStateList = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(5).Where(x => x.ID == 24));
            }
            else
            {
                this.RequestStateList = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(5).Where(x => x.ID != 24));
            }
            this.RequestTypeList = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(4));
            int SessionGroupID;

            if (ContextStudent == null)
            {
                SessionGroupID = sessionGroupID;
            }
            else
            {
                SessionGroupID = TeamDal.FindById(ContextStudent.TeamID).SessionGroupID;
            }
            this.ProviderTeamList          = new ObservableCollection <Team>(TeamDal.FindAll(x => x.SessionGroupID == SessionGroupID));
            this.AvailableServiceStoreList = ReloadServiceStoreList();
        }
        private void CreateServiceRequest()
        {
            ServiceRequest newRequest = new ServiceRequest
            {
                RequesterTeamID = ContextStudent.TeamID,
                RequestState    = DictionaryDal.DictionaryListByType(5).Where(x => x.ID == 21).FirstOrDefault().ID,
                RequestNumber   = 0
            };
            ServiceRequestWindow target = new ServiceRequestWindow(0, newRequest, ContextStudent, "")
            {
                Owner = this.SourceWindow
            };

            SwitchWindows(target, true);
            this.RequestedRequestsList = ReloadRequestedRequests();
            this.ProvidedRequestsList  = ReloadProvidedRequestsList();
        }
        private void SaveRequest(object param)
        {
            ServiceStore selectedServiceStore = (ServiceStore)((DataGrid)param).SelectedItem;

            SelectedServiceRequest.RequestType = SelectedServiceRequestTypeID;
            if (SelectedServiceRequest.RequestType == DictionaryDal.DictionaryListByType(4).Where(x => x.ID == 19).FirstOrDefault().ID&& selectedServiceStore == null)
            {
                MessageBox.Show("Módosítási igényhez szolgáltatás kijelölése szükséges!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                if (SelectedServiceRequest.RequestType == DictionaryDal.DictionaryListByType(4).Where(x => x.ID == 19).FirstOrDefault().ID&& selectedServiceStore != null)
                {
                    SelectedServiceRequest.ServiceID = selectedServiceStore.ID;
                }
                else
                {
                    SelectedServiceRequest.ServiceID = null;
                }
                SelectedServiceRequest.ProviderTeamID = SelectedProviderTeamID;

                if (SelectedServiceRequest.AssigneeID != null && SelectedServiceRequest.RequestState == DictionaryDal.DictionaryListByType(5).Where(x => x.ID == 21).FirstOrDefault().ID)
                {
                    SelectedServiceRequest.RequestState = DictionaryDal.DictionaryListByType(5).Where(x => x.ID == 22).FirstOrDefault().ID;
                }
                if (SelectedServiceRequest.ID == 0)
                {
                    SelectedServiceRequest.CreatorID = ContextStudent.ID;
                    _contextDal.Create(SelectedServiceRequest);
                }
                else
                {
                    _contextDal.Update(SelectedServiceRequest);
                }
                this.SourceWindow.Close();
            }
        }
        private void FillFilters(bool filteredFilter)
        {
            if (!filteredFilter)
            {
                RequesterTeamList = new ObservableCollection <Team>(TeamList);
                ProviderTeamList  = new ObservableCollection <Team>(TeamList);
                RequestStateList  = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(5));
                RequestTypeList   = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(4));
            }
            RequestCreatorList  = new ObservableCollection <Student>();
            RequestAssigneeList = new ObservableCollection <Student>();
            int?RequesterTeamFilterID = RequesterTeamFilter?.ID;

            if (RequesterTeamFilterID != null)
            {
                RequestCreatorList = new ObservableCollection <Student>(new StudentDAL().FindAll(x => x.TeamID == RequesterTeamFilter.ID));
            }
            int?ProviderTeamFilterID = ProviderTeamFilter?.ID;

            if (ProviderTeamFilterID != null)
            {
                RequestAssigneeList = new ObservableCollection <Student>(new StudentDAL().FindAll(x => x.TeamID == ProviderTeamFilter.ID));
            }
        }
        public ServiceStoreParamAddViewModel(ServiceStoreParamAddWindow sourceWindow, ServiceStore selectedServiceStore, ServiceStoreParams serviceStoreParam)
        {
            this.SourceWindow         = sourceWindow;
            this.SelectedServiceStore = selectedServiceStore;
            this._contextDal          = new ServiceStoreParamsDAL();
            this.TeamDal               = new TeamDAL();
            this.ServiceTableDal       = new ServiceTableDAL();
            this.ServiceTableFieldDal  = new ServiceTableFieldDAL();
            this.ServiceStoreParamsDal = new ServiceStoreParamsDAL();
            this.ServiceStoreDal       = new ServiceStoreDAL();
            this.DictionaryDal         = new DictionaryDAL();

            this.SessionGroupID                    = TeamDal.FindById(selectedServiceStore.ProviderTeamID).SessionGroupID;
            this.TeamFilter                        = TeamDal.FindById(SelectedServiceStore.ProviderTeamID);
            this.SessionGroupTeamList              = new ObservableCollection <Team>(TeamDal.FindAll(x => x.SessionGroupID == SessionGroupID));
            this.TableList                         = ReloadServiceTableList();
            this.TableFieldList                    = ReloadServiceTableFieldList();
            this.SelectedServiceStoreParam         = serviceStoreParam;
            SelectedServiceStoreParam.ServiceStore = SelectedServiceStore;
            CustomFieldTypeList                    = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(3));
            this.SaveCommand                       = new RelayCommand(SaveParameter, CanSaveParameter);
        }
 private bool CanApproveRequest(object param)
 {
     return(((DataGrid)param).SelectedItem != null && DictionaryDal.FindById(((ServiceRequest)((DataGrid)param).SelectedItem).RequestState).ItemName == "Jóváhagyásra vár");
 }