private static void UpdateSection(Project project, Section section) { foreach (var task in section.Tasks) { UpdateEstimate(project, task); // update parent totals section.TotalTasks += task.TotalTasks; section.TotalHours += task.TotalHours; } // calculate weeks after children total var hoursPerWeek = (double)project.HoursPerWeek; section.TotalWeeks = Math.Round(section.TotalHours / hoursPerWeek, 2); }
public static Project Create() { var project = new Project { HoursPerWeek = 30, ContingencyRate = 10, Id = ObjectId.GenerateNewId().ToString(), Name = "New Project", Created = DateTime.Now, Creator = UserName.Current(), Updated = DateTime.Now, Updater = UserName.Current() }; project.Assumptions.Add("Project Assumption"); var presentationFactor = new Factor { Id = ObjectId.GenerateNewId().ToString(), Name = "Presentation Factor", VerySimple = 2, Simple = 4, Medium = 8, Complex = 16, VeryComplex = 32, }; project.Factors.Add(presentationFactor); var backendFactor = new Factor { Id = ObjectId.GenerateNewId().ToString(), Name = "Back-End Logic Factor", VerySimple = 2, Simple = 4, Medium = 8, Complex = 16, VeryComplex = 32, }; project.Factors.Add(backendFactor); var section = new Section { Id = ObjectId.GenerateNewId().ToString(), Name = "Application Section", }; project.Sections.Add(section); var presentationEstimate = new Task { Id = ObjectId.GenerateNewId().ToString(), Name = "Presentation Task", FactorId = presentationFactor.Id, }; section.Tasks.Add(presentationEstimate); var backendEstimate = new Task { Id = ObjectId.GenerateNewId().ToString(), Name = "Back-End Logic Task", FactorId = backendFactor.Id, }; section.Tasks.Add(backendEstimate); return project; }
public Project GenerateProject(string organizationId) { if (organizationId == null) throw new ArgumentNullException("organizationId"); var project = new Project { Id = ObjectId.GenerateNewId().ToString(), Name = "Sample Project", Description = "Generated Sample Project", OrganizationId = organizationId, HoursPerWeek = 30, ContingencyRate = 10, Created = DateTime.Now, Creator = UserName.Current(), Updated = DateTime.Now, Updater = UserName.Current() }; project.Assumptions.Add("Project Assumption"); var presentationFactor = new Factor { Id = ObjectId.GenerateNewId().ToString(), Name = "Presentation Factor", VerySimple = 2, Simple = 4, Medium = 8, Complex = 16, VeryComplex = 32, }; project.Factors.Add(presentationFactor); var backendFactor = new Factor { Id = ObjectId.GenerateNewId().ToString(), Name = "Back-End Logic Factor", VerySimple = 2, Simple = 4, Medium = 8, Complex = 16, VeryComplex = 32, }; project.Factors.Add(backendFactor); var dataFactor = new Factor { Id = ObjectId.GenerateNewId().ToString(), Name = "Data Model Factor", VerySimple = 1, Simple = 2, Medium = 4, Complex = 8, VeryComplex = 16, }; project.Factors.Add(dataFactor); var section = new Section { Id = ObjectId.GenerateNewId().ToString(), Name = "Application Sample Section", }; project.Sections.Add(section); var presentationEstimate = new Task { Id = ObjectId.GenerateNewId().ToString(), Name = "Presentation Task", FactorId = presentationFactor.Id, Medium = 1, Simple = 1 }; section.Tasks.Add(presentationEstimate); var backendEstimate = new Task { Id = ObjectId.GenerateNewId().ToString(), Name = "Back-End Logic Task", FactorId = backendFactor.Id, Complex = 1, Simple = 1 }; section.Tasks.Add(backendEstimate); ProjectCalculator.UpdateTotals(project); return project; }