コード例 #1
0
        static public List <SubTask> GetSubTasks(int taskId, char?status)
        {
            string query = "SELECT * FROM `subtasks` WHERE  `task_id` = '" + taskId + "'";

            if (status != null)
            {
                query += "AND `status` = '" + status + "'";
            }
            List <SubTask> tasks           = new List <SubTask>();
            MySqlCommand   databaseCommand = new MySqlCommand(query, DatabaseConnection.databaseConnection);

            databaseCommand.CommandTimeout = 60;

            try
            {
                DatabaseConnection.databaseConnection.Open();
                MySqlDataReader myReader = databaseCommand.ExecuteReader();
                if (myReader.HasRows)
                {
                    while (myReader.Read())
                    {
                        SubTask tmpTask = new SubTask((int)myReader["id"], myReader["name"].ToString(), taskId);
                        if ((string)myReader["description"] != null)
                        {
                            tmpTask.SetDescription((string)myReader["description"]);
                        }
                        if (myReader["deadline"] != null)
                        {
                            Console.WriteLine(myReader);
                            tmpTask.SetDeadline(DateTime.Parse(myReader["deadline"].ToString()));
                        }
                        tasks.Add(tmpTask);
                    }
                }
                else
                {
                    Console.WriteLine(myReader);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            DatabaseConnection.databaseConnection.Close();


            return(tasks);
        }
コード例 #2
0
ファイル: Db.cs プロジェクト: natalijaN/ASP.Net-MVC
        static Db()
        {
            User john = new User()
            {
                Id              = 1,
                FirstName       = "John",
                LastName        = "Doe",
                AverageFreeTime = 5
            };

            Users.Add(john);

            ToDo basketball = new ToDo()
            {
                Id              = 1,
                Title           = "Basketball Training",
                ImporanceOfTask = ImporanceOfTask.Medium,
                Status          = Status.InProgress,
                Type            = Models.DomainModels.Type.Hobby,
            };

            SubTask workout = new SubTask()
            {
                Id         = 1,
                Title      = "Workout",
                Descrition = "Workout before Training",
                SubStatus  = SubStatus.NotDone
            };

            SubTask spa = new SubTask()
            {
                Id         = 2,
                Title      = "Spa",
                Descrition = "Spa after Training",
                SubStatus  = SubStatus.NotDone
            };

            basketball.SubTasks.Add(workout);
            basketball.SubTasks.Add(spa);

            ToDo project = new ToDo()
            {
                Id              = 2,
                Title           = "Project",
                ImporanceOfTask = ImporanceOfTask.Important,
                Status          = Status.NotDone,
                Type            = Models.DomainModels.Type.Work,
            };

            SubTask analyze = new SubTask()
            {
                Id         = 3,
                Title      = "Analyze",
                Descrition = "Analyze Data",
                SubStatus  = SubStatus.Done
            };

            SubTask design = new SubTask()
            {
                Id         = 4,
                Title      = "Design",
                Descrition = "Design Engine",
                SubStatus  = SubStatus.NotDone
            };

            project.SubTasks.Add(analyze);
            project.SubTasks.Add(design);


            ToDo readABook = new ToDo()
            {
                Id              = 3,
                Title           = "Reading Book",
                ImporanceOfTask = ImporanceOfTask.Important,
                Status          = Status.Done,
                Type            = Models.DomainModels.Type.Personal,
            };

            SubTask goToLibrary = new SubTask()
            {
                Id         = 5,
                Title      = "Go to the library",
                Descrition = "Go to the library",
                SubStatus  = SubStatus.Done
            };

            SubTask readTheBook = new SubTask()
            {
                Id        = 6,
                Title     = "ReadTheBook",
                SubStatus = SubStatus.NotDone
            };

            readABook.SubTasks.Add(goToLibrary);
            readABook.SubTasks.Add(readTheBook);

            john.ToDos.Add(basketball);
            john.ToDos.Add(project);
            john.ToDos.Add(readABook);

            UserId    = 1;
            ToDoId    = 3;
            SubTaskId = 6;
        }