Ejemplo n.º 1
0
        private ProjectTask CreateProjectTask(Project project, string subject, string notes, ProjectTaskStatus status, Person assignedTo)
        {
            ProjectTask task = ObjectSpace.FindObject <ProjectTask>(new BinaryOperator("Subject", subject));

            if (task == null)
            {
                task            = ObjectSpace.CreateObject <ProjectTask>();
                task.Project    = project;
                task.Subject    = subject;
                task.Notes      = notes;
                task.Status     = status;
                task.AssignedTo = assignedTo;
                if (task.Status == ProjectTaskStatus.InProgress || task.Status == ProjectTaskStatus.Completed)
                {
                    task.StartDate = DateTime.Now.AddDays(rnd.Next(1) * (-1));
                }
                if (task.Status == ProjectTaskStatus.Completed)
                {
                    task.EndDate = DateTime.Now.AddDays(rnd.Next(2));
                }
                task.Save();
            }
            return(task);
        }