public static Project ToProject(SerializableProject item) { var working = new Project { Name = item.Name, Description = item.Description, Organization = SerializableOrganization.ToOrganization(item.Organization), }; foreach (var itemFixedCost in item.FixedCosts) { working.FixedCosts.Add(itemFixedCost); } // Add all the tasks to the project tasks, but without linking foreach (var serTask in item.Tasks) { working.AddTask(SerializablePertTask.ToUnlinkedPertTask(serTask)); } // Now go through and link and add employees foreach (var serTask in item.Tasks) { var actualTask = working.GetTaskById(serTask.Id); foreach (Guid descendantId in serTask.Descendants) { var descendant = working.GetTaskById(descendantId); actualTask.LinkToDescendant(descendant); } } return(working); }
public static SerializableProject FromProject(Project item) { return(new SerializableProject { Name = item.Name, Description = item.Description, Tasks = item.Tasks.Select(SerializablePertTask.FromPertTask).ToList(), Organization = SerializableOrganization.FromOrganization(item.Organization), FixedCosts = item.FixedCosts.ToList() }); }
public static Organization ToOrganization(SerializableOrganization item) { var working = new Organization { Name = item.Name, Description = item.Description, ResourceGroups = item.ResourceGroups, Employees = new List <Employee>() }; foreach (var serializableEmployee in item.Employees) { working.Employees.Add(new Employee { Name = serializableEmployee.Name, Group = working.ResourceGroups.FirstOrDefault(x => x.Name == serializableEmployee.ResourceGroupName) }); } return(working); }