Пример #1
0
        //public DelegateCommand SaveProject { get; set; }
        #endregion
        public MainViewModel()
        {
            //Session = new EMSSession();
            Session = new EnumSession();

            //try
            {
                Projects = SimpleProjectViewModel.GetAll(Session);
                //MIGRATE HERE
                //Migration(Projects, 4);

                ViewColProjects = CollectionViewSource.GetDefaultView(Projects);
            }
            //catch (Exception ex)
            //{
            //   while (ex.InnerException != null)
            //      ex = ex.InnerException;
            //   MessageBox.Show("Error with getting projects:" + ex.Message);
            //}

            //Binding b = new Binding("Projects");
            //b.Source = Projects;
            //b.Mode = BindingMode.OneWay;
            //BindingOperations.SetBinding(, CollectionViewSource.SourceProperty, b);

            ViewColProjects.Filter = filterAll;
            FontIncrease           = new Prism.Commands.DelegateCommand(() => ++ FontSize);
            FontDecrease           = new Prism.Commands.DelegateCommand(() => -- FontSize);
            SaveAsExcel            = new Prism.Commands.DelegateCommand(saveToExcel);
            NewProjectCommand      = new Prism.Commands.DelegateCommand(NewProject);
        }
Пример #2
0
        public async Task <List <SimpleProjectViewModel> > ReadProjectWhereUserBelongs(int userId)
        {
            var queryFactory = _dataAccess.GetQueryFactory(_connectionString);

            var projectQuery = queryFactory.Query(TableConstants.ProjectTable);
            var membersQuery = queryFactory.Query(TableConstants.MembersTable)
                               .Where(MemberConstants.UserId, userId)
                               .Include(TableConstants.ProjectTable, projectQuery,
                                        ProjectConstants.ProjectId, MemberConstants.ProjectId);


            var items = (await membersQuery.GetAsync()).Cast <IDictionary <string, object> >().ToList();

            var listOfSimpleProjects = new List <SimpleProjectViewModel>();

            foreach (var item in items)
            {
                var dictionary    = (IDictionary <string, object>)item[TableConstants.ProjectTable];
                var simpleProject = new SimpleProjectViewModel
                {
                    MyId               = (int)dictionary[ProjectConstants.ProjectId],
                    MyProjectName      = (string)dictionary[ProjectConstants.ProjectName],
                    MyClientId         = (int)dictionary[ProjectConstants.ClientId],
                    MyEndDate          = (DateTime)dictionary[ProjectConstants.EndDate],
                    MyStartDate        = (DateTime)dictionary[ProjectConstants.StartDate],
                    MyProjectCode      = (string)dictionary[ProjectConstants.ProjectCode],
                    MyProjectStatus    = (ProjectStatusEnum)dictionary[ProjectConstants.StatusId],
                    MyProjectType      = (ProjectTypeEnum)dictionary[ProjectConstants.CodProjectType],
                    MyCreatorId        = (int)dictionary[ProjectConstants.CreatorId],
                    MyProjectManagerId = (int)dictionary[ProjectConstants.ProjectManagerId]
                };
                listOfSimpleProjects.Add(simpleProject);
            }
            return(listOfSimpleProjects);
        }
Пример #3
0
        public bool filterAll(object o)
        {
            SimpleProjectViewModel p = o as SimpleProjectViewModel;

            if (o == null)
            {
                return(false);
            }
            foreach (var f in _GridFilters)
            {
                if (!f.Value.Invoke(p))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #4
0
 private void NewProject()
 {
     SelectedProject = new SimpleProjectViewModel(Session);
     NewProjectCommand.RaiseCanExecuteChanged();
 }