diff --git a/checkpoint3/.vs/ProjectSettings.json b/checkpoint3/.vs/ProjectSettings.json new file mode 100644 index 00000000..f8b48885 --- /dev/null +++ b/checkpoint3/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/checkpoint3/.vs/checkpoint3/v15/.suo b/checkpoint3/.vs/checkpoint3/v15/.suo new file mode 100644 index 00000000..e16fd41e Binary files /dev/null and b/checkpoint3/.vs/checkpoint3/v15/.suo differ diff --git a/checkpoint3/.vs/slnx.sqlite b/checkpoint3/.vs/slnx.sqlite new file mode 100644 index 00000000..69842c72 Binary files /dev/null and b/checkpoint3/.vs/slnx.sqlite differ diff --git a/checkpoint3/.vscode/launch.json b/checkpoint3/.vscode/launch.json new file mode 100644 index 00000000..4d9cff12 --- /dev/null +++ b/checkpoint3/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/checkpoint3.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window + "console": "internalConsole", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ,] +} \ No newline at end of file diff --git a/checkpoint3/.vscode/tasks.json b/checkpoint3/.vscode/tasks.json new file mode 100644 index 00000000..d29abe04 --- /dev/null +++ b/checkpoint3/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/checkpoint3.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/checkpoint3/Program.cs b/checkpoint3/Program.cs new file mode 100644 index 00000000..6af96896 --- /dev/null +++ b/checkpoint3/Program.cs @@ -0,0 +1,106 @@ +using System; +using System.Linq; +using System.Collections; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + + + +namespace checkpoint3 +{ + class Program + { + static void Main(string[] args) + { + DbContextOptionsBuilder builder = new DbContextOptionsBuilder(); + builder.UseSqlServer("Server=(localdb)\\MSSQLLocalDB;Database=BlogDb;Trusted_Connection=true"); + DbContextOptions opts = builder.Options; + Utils context = new Utils(opts); + + context.Database.EnsureCreated(); + + ToDo todo1 = new ToDo(); + ToDo todo2 = new ToDo(); + ToDo todo3 = new ToDo(); + ToDo todo4 = new ToDo(); + + context.CreateToDo(todo1); + System.Console.WriteLine("What task do you want to complete?"); + todo1.Description = Console.ReadLine(); + context.PrintToDos(context.ToDos); + context.CreateToDo(todo2); + Console.WriteLine("Enter additional tasks if needed:"); + todo2.Description = Console.ReadLine(); + context.PrintToDos(context.ToDos); + context.CreateToDo(todo3); + Console.WriteLine("Enter additional tasks if needed:"); + todo3.Description = Console.ReadLine(); + context.PrintToDos(context.ToDos); + context.CreateToDo(todo4); + Console.WriteLine("Enter additional tasks if needed:"); + todo4.Description = Console.ReadLine(); + context.PrintToDos(context.ToDos); + + System.Console.WriteLine("Id of task you want to update: "); + int id = Convert.ToInt32(Console.ReadLine()); + System.Console.WriteLine("What would you like to change it to?"); + string newdesc = Console.ReadLine(); + context.UpdateToDo(id, newdesc); + context.PrintToDos(context.ToDos); + + //Console.WriteLine("Would you like to Add,Edit, or Delete any tasks>"); + //string answer = Console.ReadLine(); + //string[] commands = { "Edit", "Add", "Delete" }; + + + + + + //List commands { "Edit", "Add", "Delete" }; + //while (answer == ) + // if (answer == "Edit") + // { + // System.Console.WriteLine("Id of task you want to update: "); + // int id = Convert.ToInt32(Console.ReadLine()); + // System.Console.WriteLine("What would you like to change it to?"); + // string newdesc = Console.ReadLine(); + // context.UpdateToDo(id, newdesc); + // context.PrintToDos(context.ToDos); + + // } + // else if (answer == "Add") + // { + // context.CreateToDo(todo1); + // System.Console.WriteLine("What task do you want to complete?"); + // todo1.Description = Console.ReadLine(); + // context.PrintToDos(context.ToDos); + // context.CreateToDo(todo2); + // Console.WriteLine("Enter additional tasks if needed:"); + // todo2.Description = Console.ReadLine(); + // context.PrintToDos(context.ToDos); + // context.CreateToDo(todo3); + // Console.WriteLine("Enter additional tasks if needed:"); + // todo3.Description = Console.ReadLine(); + // context.PrintToDos(context.ToDos); + // context.CreateToDo(todo4); + // Console.WriteLine("Enter additional tasks if needed:"); + // todo4.Description = Console.ReadLine(); + // context.PrintToDos(context.ToDos); + // } + // else if (answer == "Delete") + // { + // context.DeleteToDo(); + // } + + + + + + System.Console.ReadLine(); + + + } + + } + +} diff --git a/checkpoint3/SQLQuery1.sql b/checkpoint3/SQLQuery1.sql new file mode 100644 index 00000000..e8965d83 --- /dev/null +++ b/checkpoint3/SQLQuery1.sql @@ -0,0 +1,9 @@ +Create Table checkpoint3 ( + TaskID int, + Description varchar(255), +); + +CREATE TABLE todo_list (id INTEGER PRIMARY KEY, item TEXT); +INSERT INTO todo_list VALUES (1, "Wash the dishes"); +INSERT INTO todo_list VALUES (2, "vacuuming"); +INSERT INTO todo_list VALUES (3, "Learn some stuff on KA"); diff --git a/checkpoint3/ToDo.cs b/checkpoint3/ToDo.cs new file mode 100644 index 00000000..9e22876a --- /dev/null +++ b/checkpoint3/ToDo.cs @@ -0,0 +1,16 @@ +using System; +using System.Linq; +using System.Collections; +using System.Collections.Generic; + +namespace checkpoint3 +{ + class ToDo + { + public int Id { get; set; } + + public string Description { get; set; } + + public string TastTitle { get; set; } + } +} \ No newline at end of file diff --git a/checkpoint3/checkpoint3.csproj b/checkpoint3/checkpoint3.csproj new file mode 100644 index 00000000..92c5fd37 --- /dev/null +++ b/checkpoint3/checkpoint3.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp2.2 + + + + + + + diff --git a/checkpoint3/utils.cs b/checkpoint3/utils.cs new file mode 100644 index 00000000..36386006 --- /dev/null +++ b/checkpoint3/utils.cs @@ -0,0 +1,56 @@ +using System; +using System.Linq; +using System.Collections; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + + +namespace checkpoint3 +{ + class Utils : DbContext + { + public Utils(DbContextOptions options) : base(options) + { + + } + public List ToDos = new List(); + public int count; + + public ToDo GetToDoByID(int id) + { + return ToDos.FirstOrDefault(x => x.Id == id); + } + + + public void UpdateToDo(int Id, string newdesc) + { + ToDo todo = GetToDoByID(Id); + todo.Description = newdesc; + } + + + public void DeleteToDo() + { + + } + + + public void CreateToDo(ToDo todo) + { + count++; + todo.Id = count; + ToDos.Add(todo); + + + } + + + public void PrintToDos(List toDos) + { + foreach (var item in toDos) + { + System.Console.WriteLine("Task ID: " + item.Id + ", and the description: " + item.Description); + } + } + } +}