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); }
/// <summary> /// Converts a SerializeablePertTask into a PertTask, but without the resource /// list or any linking /// </summary> /// <param name="item"></param> /// <returns></returns> public static PertTask ToUnlinkedPertTask(SerializablePertTask item) { var working = new PertTask { Name = item.Name, Id = item.Id, Description = item.Description, TimeEstimate = item.TimeEstimate, Resources = new HashSet <IResource>(), Category = item.Category }; if (working.TimeEstimate == null) { working.TimeEstimate = new Estimate(); } return(working); }