示例#1
0
        public List <MyProjectViewModel> GetProjectsbyMemberId(int memberId)
        {
            var myProjectsListVM = new List <MyProjectViewModel>();

            var ProjectItems = _repository.GetAll <Project>().Where(m => m.MemberId == memberId);

            var DraftProjectItems = _repository.GetAll <DraftProject>().Where(dp => dp.MemberId == memberId);

            foreach (Project entity in ProjectItems)
            {
                var myProjectVM = new MyProjectViewModel
                {
                    ProjectId       = entity.ProjectId,
                    ProjectName     = entity.ProjectName,
                    ProjectCoverUrl = entity.ProjectCoverUrl,
                    GoalMoney       = entity.AmountThreshold,
                    CreatedDate     = entity.CreatedDate,
                    LastEditTime    = entity.LastEditTime,
                    SubmittedDate   = entity.SubmittedDate,
                    ApprovingStatus = entity.ApprovingStatus,
                    ProjectStatus   = entity.ProjectStatus,
                    EndDate         = entity.EndDate,
                    StartDate       = entity.StartDate,
                    ProjectMainUrl  = entity.ProjectMainUrl,
                };
                myProjectsListVM.Add(myProjectVM);
            }
            return(myProjectsListVM);
        }
示例#2
0
        public MyProjectView()
        {
            this.InitializeComponent();

            var viewModel = new MyProjectViewModel(new NavigationService());

            this.viewModel   = viewModel;
            this.DataContext = this.viewModel;
        }
示例#3
0
        /// <summary>
        /// Function for creating Client Dashboard View Model
        /// </summary>
        /// <param name="projectsList">Projects list from Database</param>
        /// <returns>created MainDashboardViewModel</returns>

        private MainDashboardViewModel CreateDashboardViewModel(IList <Project> projectsList)
        {
            var viewModel = new MainDashboardViewModel();

            var viewModelProjects = new List <MyProjectViewModel>();

            foreach (var project in projectsList)
            {
                var viewModelProject = new MyProjectViewModel {
                    Id            = project.Id,
                    Title         = project.Title,
                    Description   = project.Description,
                    ClientCompany = project.ClientCompany,
                    ClientEmail   = project.ClientEmail,
                    StartDate     = project.StartDate,
                    EndDate       = project.EndDate,
                    Stage         = project.Stage,
                    IsPublic      = project.IsPublic
                };

                if (project.ProjectOwner != null)
                {
                    viewModelProject.ProjectOwnerName    = project.ProjectOwner.Name;
                    viewModelProject.ProjectOwnerSurname = project.ProjectOwner.Surname;
                    viewModelProject.ProjectOwnerEmail   = project.ProjectOwner.Email;
                }

                if (project.StartDate != null && project.EndDate != null)
                {
                    TimeSpan durationTime = project.EndDate - project.StartDate;
                    viewModelProject.Duration = (int)durationTime.TotalDays;
                }

                if (project.Tasks.Count() > 0)
                {
                    var done    = project.Tasks.Where(t => t.Status == Status.Done).Count();
                    var total   = project.Tasks.Count();
                    var percent = (double)done / total * 100;
                    viewModelProject.Completeness = (int)percent;
                }

                if (project.EndDate != null)
                {
                    var      dateNow          = DateTime.Now;
                    TimeSpan timeTillDeadline = project.EndDate - dateNow;
                    viewModelProject.TillDeadline = (int)timeTillDeadline.TotalDays;
                }

                viewModelProjects.Add(viewModelProject);
            }

            viewModel.WorkingOnProjectsList   = viewModelProjects.Where(p => p.Stage == Stage.InProgress).ToList();
            viewModel.DoneProjectsList        = viewModelProjects.Where(p => p.Stage == Stage.Completed).ToList();
            viewModel.NewProjectsList         = viewModelProjects.Where(p => p.Stage == Stage.New).ToList();
            viewModel.UnconfirmedProjectsList = viewModelProjects.Where(p => p.Stage == Stage.Unconfirmed).ToList();

            viewModel.WorkingOnProjectsCount   = viewModel.WorkingOnProjectsList.Count();
            viewModel.DoneProjectsCount        = viewModel.DoneProjectsList.Count();
            viewModel.NewProjectsCount         = viewModel.NewProjectsList.Count();
            viewModel.UnconfirmedProjectsCount = viewModel.UnconfirmedProjectsList.Count();

            return(viewModel);
        }
示例#4
0
        private IList <MyProjectViewModel> ViewModelListFromProjectModelList(IList <Project> projectsList)
        {
            var viewModelProjects = new List <MyProjectViewModel>();

            foreach (var project in projectsList)
            {
                var viewModelProject = new MyProjectViewModel
                {
                    Id            = project.Id,
                    Title         = project.Title,
                    Description   = project.Description,
                    ClientCompany = project.ClientCompany,
                    ClientEmail   = project.ClientEmail,
                    StartDate     = project.StartDate,
                    EndDate       = project.EndDate,
                    Stage         = project.Stage,
                    IsPublic      = project.IsPublic,
                };

                if (project.Tasks.Count() > 0)
                {
                    var done    = project.Tasks.Where(t => t.Status == Status.Done).Count();
                    var total   = project.Tasks.Count();
                    var percent = (double)done / total * 100;
                    viewModelProject.Completeness = (int)percent;
                }

                if (project.ProjectOwner != null)
                {
                    viewModelProject.ProjectOwner = new PersonMainDashboardViewModel(project.ProjectOwner.Name, project.ProjectOwner.Surname, project.ProjectOwner.Email);
                }
                else
                {
                    viewModelProject.ProjectOwner = new PersonMainDashboardViewModel();
                }

                if (project.ScrumMaster != null)
                {
                    viewModelProject.ScrumMaster = new PersonMainDashboardViewModel(project.ScrumMaster.Name, project.ScrumMaster.Surname, project.ScrumMaster.Email);
                }
                else
                {
                    viewModelProject.ScrumMaster = new PersonMainDashboardViewModel();
                }

                if (project.StartDate != null && project.EndDate != null)
                {
                    TimeSpan durationTime = project.EndDate - project.StartDate;
                    viewModelProject.Duration = (int)durationTime.TotalDays;
                }

                if (project.Tasks.Count() > 0)
                {
                    var done    = project.Tasks.Where(t => t.Status == Status.Done).Count();
                    var total   = project.Tasks.Count();
                    var percent = (double)done / total * 100;
                    viewModelProject.Completeness = (int)percent;
                }

                if (project.EndDate != null)
                {
                    var      dateNow          = DateTime.Now;
                    TimeSpan timeTillDeadline = project.EndDate - dateNow;
                    viewModelProject.TillDeadline = (int)timeTillDeadline.TotalDays;
                }

                if (project.Team != null && project.Team.Count > 0)
                {
                    foreach (var teamMember in project.Team)
                    {
                        viewModelProject.Team.Add(new PersonMainDashboardViewModel(teamMember.Person.Name, teamMember.Person.Surname, teamMember.Person.Email));
                    }
                }

                viewModelProjects.Add(viewModelProject);
            }

            return(viewModelProjects);
        }