public ProjectModel GetProject(int id) { ProjectModel content = null; // Get project from DB Core.Model.Project project = projectRepository.GetProject(id); //Mapp to UI model if (project != null) { content = ApplicationMapper.MapProjectContent(project); } return(content); }
/// <summary> /// Writes the section using an XML writer /// </summary> /// <param name="writer">XML writer to use</param> /// <param name="project">The project to generate .csproj for</param> /// <param name="context">Current .vcxproj generation context</param> public override void Write(System.Xml.XmlWriter writer, Core.Model.Project project, VsCore.VisualStudio.IMSBuildProjectGeneratorContext context) { if (context.VersionOutput != null && project.GetVersionSupport()) { // Generating the version file (C# source code) var generator = new CppVersionInfoGenerator(project); generator.Generate(context.VersionOutput); // Adding reference to it to the .csproj file writer.WriteStartElement("ItemGroup"); writer.WriteStartElement("ClCompile"); writer.WriteAttributeString("Include", Path.Combine("..", context.VersionFileName)); writer.WriteEndElement(); writer.WriteEndElement(); } }
public static ProjectModel MapProjectContent(Core.Model.Project p) { var uiModel = new ProjectModel(); uiModel.Id = p.Id; uiModel.Name = p.Name; uiModel.AreaId = p.ProjectAreaId; uiModel.OrganizationId = p.OrganizationId; uiModel.PhaseId = p.PhaseId; uiModel.Phase = EnumHelper.GetEnumDescription((Phase)p.PhaseId); uiModel.Program = p.Program; uiModel.YammerGroup = p.YammerGroup; if (p.StartDate.HasValue) { uiModel.StartDate = p.StartDate.Value.GetMyLocalTime(); } uiModel.CreatedById = p.CreatedById; uiModel.CreatedBy = p.User.Name; uiModel.Description = p.Description; uiModel.FundingEstimate = p.FundingEstimate; uiModel.FundingActual = p.FundingActual; uiModel.FundingExternal = p.FundingExternal; uiModel.FundingStimulus = p.FundingStimulus; uiModel.IntroductionBackground = p.PlanIntroductionBackground; uiModel.IntroductionDefinition = p.PlanIntroductionDefinition; uiModel.IntroductionComments = p.PlanIntroductionComments; uiModel.DescriptionExtent = p.PlanDescriptionExtent; uiModel.DescriptionDelimitation = p.PlanDescriptionDelimitation; uiModel.DescriptionManagement = p.PlanDescriptionManagement; uiModel.DescriptionEvaluation = p.PlanDescriptionEvaluation; uiModel.ImplementationDescription = p.PlanImplementationDescription; uiModel.CommunicationInterestAnalysis = p.PlanCommunicationInterestAnalysis; uiModel.CommunicationDefinition = p.PlanCommunicationDefinition; uiModel.CommunicationPlan = p.PlanCommunicationPlan; uiModel.PublishDate = p.PublishedDate.GetMyLocalTime(); uiModel.Debriefing = p.Debriefing; uiModel.Members = new List <MemberModel>(); foreach (ProjectMemberView member in p.ProjectMembers) { MemberModel memberModel = new MemberModel(); memberModel.Id = member.ProjectMemberId; memberModel.UserId = member.UserId; memberModel.ProjectId = p.Id; memberModel.Name = member.UserName; memberModel.Email = member.UserEmail; memberModel.Municipality = member.Organization; memberModel.isSaved = true; memberModel.MemberRoles = new List <RoleModel>(); foreach (ProjectRoleView roleView in member.ProjectRoles) { memberModel.MemberRoles.Add(new RoleModel { Id = roleView.ProjectRoleId, Name = roleView.ProjectRoleName, ProjectRoleGroupName = roleView.ProjectRoleGroupName }); } memberModel = ObjectTextTrim.TrimStringProperties(memberModel); uiModel.Members.Add(memberModel); } uiModel.Risks = (from risk in p.ProjectRisks select new RiskModel { ProjectId = risk.ProjectId, Id = risk.Id, Name = risk.Name, ConsequenceId = risk.ConsequenceId, ProbabilityId = risk.ProbabilityId, Effect = risk.Effect }).ToList(); uiModel.Goals = (from goal in p.ProjectGoals select new GoalModel { ProjectId = goal.ProjectId, Id = goal.Id, Type = goal.Type, Achieved = goal.Achieved, MesaureMethod = goal.MesaureMethod, GoalDefinition = goal.GoalDefinition }).ToList(); uiModel.Activity = (from activity in p.ProjectActivities select new ActivityModel { ProjectId = activity.ProjectId, Id = activity.Id, Name = activity.Name, StatusId = activity.Status, Notes = activity.Notes, InternalHours = activity.InternalHours, ExternalHours = activity.ExternalHours, Cost = activity.Cost, SummaryRow = 0, SummaryCost = 0, SummaryInternalHours = 0, SummaryExternalHours = 0, SummaryTotal = 0, }).ToList(); if (p.Permissions != null) { uiModel.ProjectPermissions = (from permission in p.Permissions select new ProjectPermissionModel { Permission = permission.Permission, Section = Enum.GetName(typeof(PermissionSection), (int)permission.Section) }).ToList(); } uiModel.FollowUp = (from followUp in p.ProjectFollowUps select new FollowUpModel { ProjectId = followUp.ProjectId, Id = followUp.Id, Date = followUp.Date.HasValue ? followUp.Date.Value.GetMyLocalTime() : DateTimeHelper.GetMinDateTime(), Notes = followUp.Notes, InternalHours = followUp.InternalHours, ExternalHours = followUp.ExternalHours, OtherCosts = followUp.OtherCosts, ActivityTotal = followUp.ActivityTotal, Canceled = followUp.Canceled, IsOpen = false, isSaved = true, RowTotalCost = 0 }).ToList(); return(ObjectTextTrim.TrimStringProperties(uiModel)); }