public VMProject(Project p, int userId) { Title = p.Title; Description = p.Description; Collaborators = new List <VMContribution>(); if (p.Contributions != null && p.Contributions.Count > 0) { foreach (Contribution c in p.Contributions) { Collaborators.Add(new VMContribution(c)); } } Media = new List <VMProjectMedium>(); if (p.ProjectMedia != null && p.ProjectMedia.Count > 0) { foreach (ProjectMedium u in p.ProjectMedia) { Media.Add(new VMProjectMedium(u)); } } Template = (ProjectTemplate)p.Template; Id = p.Id; currentUserId = userId; if (p.Contributions != null && p.Contributions.Count > 0) { if (p.Contributions.Any(c => c.UserId == userId)) { PersonalContribution = new VMContribution(p.Contributions.FirstOrDefault(c => c.UserId == userId)); } } ProjectMasterIds = new List <int>(); ProjectEditorIds = new List <int>(); if (p.ProjectPermissions != null && p.ProjectPermissions.Count > 0) { foreach (ProjectPermission pm in p.ProjectPermissions) { if (pm.IsProjectEditor) { ProjectEditorIds.Add(pm.UserId); } if (pm.IsProjectMaster) { ProjectMasterIds.Add(pm.UserId); } } } ContributionSetting = (ContributionSetting)p.CollaborationSetting; }
public VMEditingProject(Project p, IEnumerable <User> quickContacts, int currentUserId) { Title = p.Title; Description = p.Description; Media = new List <VMProjectMedium>(); if (p.ProjectMedia != null && p.ProjectMedia.Count > 0) { foreach (ProjectMedium u in p.ProjectMedia) { Media.Add(new VMProjectMedium(u)); } } EditingCollaborators = new VMEditingCollaborators(p.Contributions, quickContacts); Template = (ProjectTemplate)p.Template; ContributionSetting = (ContributionSetting)p.CollaborationSetting; Id = p.Id; _currentUserId = currentUserId; if (p.Contributions != null && p.Contributions.FirstOrDefault(c => c.UserId == _currentUserId) != null) { PersonalContribution = new VMContribution(p.Contributions.FirstOrDefault(c => c.UserId == _currentUserId)); } else { PersonalContribution = new VMContribution(); } ProjectEditorIds = new List <int>(); ProjectMasterIds = new List <int>(); if (p.ProjectPermissions != null && p.ProjectPermissions.Count > 0) { foreach (ProjectPermission pm in p.ProjectPermissions) { if (pm.IsProjectEditor) { ProjectEditorIds.Add(pm.UserId); } if (pm.IsProjectMaster) { ProjectMasterIds.Add(pm.UserId); } } } }
public VMManagingCollaborator(VMContribution contribution, bool isProjectEditor) { if (!string.IsNullOrEmpty(contribution.Name)) { UserName = contribution.Name; } IsProjectEditor = isProjectEditor; UserId = contribution.UserId; if (!string.IsNullOrEmpty(contribution.Title)) { Title = contribution.Title; } if (!string.IsNullOrEmpty(contribution.Description)) { int length = (contribution.Description.Length >= 150)? 150: contribution.Description.Length; DescriptionShort = contribution.Description.Substring(0, length) + "..."; } ProjectId = contribution.ProjectId; }