示例#1
0
        private static void addCheckpointsService()
        {
            using (var srv = new CheckpointService())
            {
                var cp2 = new Checkpoint()
                {
                    Id = 2,
                    Title = "Checkpoint 2",
                    Description = "Sample checkpoint 2",
                    ExpectedResult = "Result checkpoint 2",
                    AuthorName = "Ukrit",
                    Rating = 2
                };

                var cp1 = new Checkpoint()
                {
                    Id = 1,
                    Title = "Checkpoint 1",
                    Description = "Sample checkpoint 1",
                    ExpectedResult = "Result checkpoint 2",
                    AuthorName = "Ukrit",
                    Rating = 1,
                    NextCheckpoint = cp2
                };
                try{
                    srv.AddCheckpoint(cp1);
                    srv.AddCheckpoint(cp2);
                    var n = srv.SaveChangesService();
                    Console.WriteLine("Insert {0} checkpoints.", n);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
示例#2
0
        private static void removeCheckpointsService()
        {
            using (var srv = new CheckpointService())
            {

                try
                {
                    var count = srv.GetAllCheckpoints().Count();
                    if (count == 0) return;

                    var firstCheckpoint = srv.GetAllCheckpoints().First();

                   // foreach (Checkpoint item in checkpointAll)
                    srv.RemoveCheckpoint(firstCheckpoint);

                    var n = srv.SaveChangesService();
                    Console.WriteLine("Deleted {0} checkpoints.", n);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }