{"id":28353098,"url":"https://github.com/rootdevelop/mywedding","last_synced_at":"2026-04-29T06:38:38.775Z","repository":{"id":79870260,"uuid":"69175155","full_name":"rootdevelop/MyWedding","owner":"rootdevelop","description":"Example app for .Net core workshop","archived":false,"fork":false,"pushed_at":"2019-01-07T15:03:26.000Z","size":2583,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-04-29T06:38:25.940Z","etag":null,"topics":["dotnet-core","entity-framework-core","workshop"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rootdevelop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-09-25T16:08:42.000Z","updated_at":"2020-02-03T11:48:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"7dc69f99-025d-41a1-9c8f-1234d46569ff","html_url":"https://github.com/rootdevelop/MyWedding","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rootdevelop/MyWedding","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootdevelop%2FMyWedding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootdevelop%2FMyWedding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootdevelop%2FMyWedding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootdevelop%2FMyWedding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rootdevelop","download_url":"https://codeload.github.com/rootdevelop/MyWedding/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootdevelop%2FMyWedding/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32414422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet-core","entity-framework-core","workshop"],"created_at":"2025-05-28T00:10:41.576Z","updated_at":"2026-04-29T06:38:38.770Z","avatar_url":"https://github.com/rootdevelop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Welcome to the ASP.Net Core workshop\n===================\n\nYou can participate in this workshop from any computer running Windows, Mac OS X or Linux.\n\nDuring this workshop the following dependencies need to be installed:\n\n- Visual Studio Code (http://code.visualstudio.com/)\n- Or Visual Studio 2017 (https://www.visualstudio.com/)\n- .NET Core 2.X (http://dot.net)\n\nDuring this workshop we'll be creating a RSVP application for an upcoming wedding.\n\n**0) Download \u0026 Restore**\n\nDownload or clone this repository and make sure the directory is called \"MyWedding\". Both Visual Studio Code and Visual Studio should automatically restore packages.\nIf they don't, please execute the following command within the MyWedding directory using the command-line or terminal:\n\n    dotnet restore\n\nAfter this all dependencies should restore and you're ready to do some programming.\n\n**1) Let's create a database**\n\nTo start off we'll have to create a database. Within ASP.Net core there is a library called Entity Framework. This allows us to generate the database tables \u0026 columns based on a POCO (Plain Old C# Object). Entity Framework also allows us to query the database using Linq instead of SQL. \n\nFor example:\n\n    _dbContext.MyTable.Where(x =\u003e x.Id == 10).First();\n\nInstead of\n\n    SELECT * FROM MyTable WHERE Id is 10;\n\nWe'll start by creating our datamodel. Open the Guest.cs file in the Models directory.\n\nWithin this Model (table) we'll define our properties (columns)\n\n    public int Id { get; set; }\n    public string Code { get; set; }\n    public string Name { get; set; }\n    public bool IsAttending { get; set; }\n    public bool HasResponded { get; set; }\n    public EMealType MealType { get; set; }\n    public string Comments { get; set; }\n      \nTo make sure Entity Framework knows about our data model we'll need to define our Guest class within the ApplicationDatabase context.\n\nTo do this, go to ApplicationDbContext.cs within the Data directory and add the following:\n\n    public DbSet\u003cGuest\u003e Guests {get; set;}\n\nGood, now Entity Framework is aware of our Guests table. Now let's execute some commands to generate this database.\n\nWithin the command-line inside the project directory execute the following commands:\n\n    dotnet ef migrations add GuestMigration\n    dotnet ef database update\n\nThe first command generates a migration script to create/update the database. The second command executes all pending migrations.\n\n**2) Let's create our Admin Area**\n\nFor our application to perform we'll need to be able to add guests to our database and view their responses.\n\nGo to the AdminController.cs file within the Controllers directory.\n\nLet's start by creating the following 2 functions:\n\n    \n        public IActionResult Index()\n        {\n            return View(_dbContext.Guests.ToList());\n        }\n         \n        [HttpPost]\n        public IActionResult AddGuest([FromForm] string code, string name)\n        {\n            var guest = new Guest();\n            guest.Code = code;\n            guest.Name = name;\n            _dbContext.Guests.Add(guest);\n            _dbContext.SaveChanges();\n\n            return View(\"Index\", _dbContext.Guests.ToList());\n        }\n\nThe first method returns an Index View on the path \"http://mywedding.com/Admin/\" the second method is a method we'll be calling from a form we'll be creating next.\n\nOpen the following view \"Index.cshtml\" within the Views/Admin folder and add the following code:\n\n    \u003cform class=\"ui form\" asp-action=\"AddGuest\"\u003e\n        \u003ch1\u003eAdd a guest\u003c/h1\u003e\n        \u003cdiv class=\"field\"\u003e\n        \u003clabel\u003eName\u003c/label\u003e\n        \u003cinput type=\"text\" name=\"name\" placeholder=\"Name\"\u003e\n        \u003c/div\u003e\n        \u003cdiv class=\"field\"\u003e\n        \u003clabel\u003eWelcome code\u003c/label\u003e\n        \u003cinput type=\"text\" name=\"code\" placeholder=\"Welcome code\"\u003e\n        \u003c/div\u003e\n        \u003cbutton class=\"ui primary button\" type=\"submit\"\u003eAdd\u003c/button\u003e\n    \u003c/form\u003e\n\nGreat, let's see if all our hard work has paid off.\n\n**3) Testing the admin area**\n\nYou can now run the application from Visual Studio Code or Visual Studio. If you want to run it from console, execute the following command inside the project directory:\n\n    dotnet run\n\nAfter this, the application will start. If everything was successful go to http://localhost:5000/Admin/ to open the admin area. Try to add some guests.\n\n**4) Let's allow people RSVP**\n\nOf course people need to be able to RSVP as well, so let's create our logic. Open the GuestController.cs within the Controllers directory and add the following methods:\n\n        [HttpPost]\n        public IActionResult Index([FromForm] string code)\n        {\n            var guest = _dbContext.Guests.FirstOrDefault(x =\u003e x.Code == code);\n\n            if (guest == null)\n            {\n                return NotFound();\n            }\n\n            return View(guest);\n        }\n\n        [HttpPost]\n        public IActionResult SaveResponse([FromForm] int id, bool isAttending, EMealType mealType, string comments)\n        {\n            var guest = _dbContext.Guests.FirstOrDefault(x =\u003e x.Id == id);\n            \n            guest.IsAttending = isAttending;\n            guest.MealType = mealType;\n            guest.Comments = comments;\n            guest.HasResponded = true;\n\n            _dbContext.Guests.Update(guest);\n            _dbContext.SaveChanges();\n\n            return View();\n        }\n\nThis logic allows us to verify someone's welcome code and save their preferences. Now let's add the corresponding view.\n\nOpen the Index.cshtml within the Views/Guest directory and add the following code:\n\n     \u003cform class=\"ui form\" asp-action=\"SaveResponse\"\u003e\n            \u003cinput type=\"hidden\" name=\"id\" value=\"@Model.Id\"\u003e\n            \u003cdiv class=\"field\"\u003e\n                \u003clabel\u003eWelcome @Model.Name\u003c/label\u003e\n            \u003c/div\u003e\n            \u003cdiv class=\"field\"\u003e\n                \u003clabel\u003eWill you be attending?\u003c/label\u003e\n                \u003cselect name=\"isAttending\" class=\"ui dropdown\"\u003e\n                    \u003coption value=true\u003eYes\u003c/option\u003e\n                    \u003coption value=false\u003eNo\u003c/option\u003e\n                \u003c/select\u003e\n            \u003c/div\u003e\n\n             \u003cdiv class=\"grouped fields\"\u003e\n                 \u003clabel\u003eMeal preference\u003c/label\u003e\n                 \u003cselect name=\"mealType\" class=\"ui dropdown\"\u003e\n                     \u003coption value=0\u003eMeat\u003c/option\u003e\n                     \u003coption value=1\u003eFish\u003c/option\u003e\n                     \u003coption value=2\u003eVegetarian\u003c/option\u003e\n                \u003c/select\u003e\n               \n            \u003c/div\u003e\n            \u003cdiv class=\"field\"\u003e\n                \u003clabel\u003eComments (food allergies, special arrangements, etc)\u003c/label\u003e\n                \u003ctextarea name=\"comments\" rows=\"3\"\u003e\u003c/textarea\u003e\n            \u003c/div\u003e\n            \u003cbutton class=\"ui primary button\" type=\"submit\"\u003eSubmit\u003c/button\u003e\n     \u003c/form\u003e\n\n**5) Let's test**\n\nRun the project again from VS Code, VS or from the command-line inside the project directory with the following command:\n\n    dotnet run\n\nAfter this, the application will start. If everything was successful go to http://localhost:5000/ to open the RSVP website. Try to enter a welcome code to see if you can enter your preferences.\n\n**6) Let's delete some guests**\n\nEveryone makes mistakes, deleting is of course essential within the admin view.\n\nLet's add the following logic to the AdminController.cs within the Controllers directory.\n\n     [HttpPost]\n        public IActionResult DeleteGuest([FromForm] int id)\n        {\n            var guest = _dbContext.Guests.FirstOrDefault(x =\u003e x.Id == id);\n            _dbContext.Guests.Remove(guest);\n            _dbContext.SaveChanges();\n            return View(\"Index\",_dbContext.Guests.ToList());\n        }\n\nAnd the following logic to the Index.cshtml in the Views/Admin directory within a new td tag.\n\n    \u003cform class=\"ui form\" asp-action=\"DeleteGuest\"\u003e\n         \u003cinput type=\"hidden\" value=\"@guest.Id\" name=\"id\" /\u003e\n         \u003cbutton class=\"ui red button\" type=\"submit\"\u003eDelete\u003c/button\u003e\n    \u003c/form\u003e\n\nDon't forget to add a corresponding column header in the correct place withing the table header\n\n    \u003cth\u003eModify\u003c/th\u003e\n\nNow we have a delete button. Let's run the application and see if this works.\n\n**7) Let's change some values**\n\nBut what if one of your guests calls you and he prefers Meat instead of Fish. Let's add some edit functionality.\n\nGo to the Index.cshtml in the Views/Admin directory and add the following line of code inside the delete form:\n\n      \u003ca asp-action=\"Edit\" asp-route-id=\"@guest.Id\" class=\"ui primary button\"\u003eEdit\u003c/a\u003e\n\nOk now let's create the Edit view. Let's create a new file called Edit.cshtml within the Views/Admin directory.\n\nWithin this file add the following code:\n\n    @using MyWedding.Models.Enums\n @model Guest\n \n \u003cdiv class=\"ui segment\"\u003e\n \n     \u003cdiv class=\"ui text centered container\"\u003e\n          \u003cform class=\"ui form\" asp-action=\"Edit\"\u003e\n         \u003cinput type=\"hidden\" name=\"id\" value=\"@Model.Id\"\u003e\n         \u003cdiv class=\"field\"\u003e\n             \u003clabel\u003eName\u003c/label\u003e\n             \u003cinput class=\"ui input\" name=\"name\" type=\"text\" value=\"@Model.Name\" /\u003e\n         \u003c/div\u003e\n         \u003cdiv class=\"field\"\u003e\n             \u003clabel\u003eWelcome code\u003c/label\u003e\n             \u003cinput class=\"ui input\" name=\"code\" type=\"text\" value=\"@Model.Code\" /\u003e\n         \u003c/div\u003e\n         \u003cdiv class=\"field\"\u003e\n             \u003clabel\u003eWill you be attending?\u003c/label\u003e\n             \u003cselect name=\"isAttending\" class=\"ui dropdown\"\u003e\n                 @if (Model.HasResponded)\n                 {\n                     @if (Model.IsAttending)\n                     {\n                         \u003coption value=true selected\u003eYes\u003c/option\u003e\n                         \u003coption value=false\u003eNo\u003c/option\u003e\n                     } \n                     else \n                     {\n                         \u003coption value=true\u003eYes\u003c/option\u003e\n                         \u003coption value=false selected\u003eNo\u003c/option\u003e\n                     }\n                 }\n                 else \n                 {\n                     \u003coption value=\"null\"\u003eUnknown\u003c/option\u003e\n                     \u003coption value=true\u003eYes\u003c/option\u003e\n                     \u003coption value=false\u003eNo\u003c/option\u003e\n                 }\n              \n             \u003c/select\u003e\n         \u003c/div\u003e\n \n          \u003cdiv class=\"grouped fields\"\u003e\n              \u003clabel\u003eMeal preference\u003c/label\u003e\n              \u003cselect name=\"mealType\" class=\"ui dropdown\"\u003e\n                  @if (Model.MealType == EMealType.Meat)\n                  {\n                     \u003coption value=0 selected\u003eMeat\u003c/option\u003e\n                  }\n                  else\n                  {\n                     \u003coption value=0\u003eMeat\u003c/option\u003e\n                  }\n \n                  @if (Model.MealType == EMealType.Fish)\n                  {\n                     \u003coption value=1 selected\u003eFish\u003c/option\u003e\n                  }\n                  else\n                  {\n                     \u003coption value=1\u003eFish\u003c/option\u003e\n                  }\n \n                  @if (Model.MealType == EMealType.Vegetarian)\n                  {\n                     \u003coption value=2 selected\u003eVegetarian\u003c/option\u003e\n                  }\n                  else\n                  {\n                     \u003coption value=2\u003eVegetarian\u003c/option\u003e\n                  }\n                  \n                 \u003c/select\u003e\n \n         \u003c/div\u003e\n         \u003cdiv class=\"field\"\u003e\n             \u003clabel\u003eComments (food allergies, special arrangements, etc)\u003c/label\u003e\n             \u003ctextarea name=\"comments\" rows=\"3\"\u003e@Model.Comments\u003c/textarea\u003e\n         \u003c/div\u003e\n         \u003cbutton class=\"ui primary button\" type=\"submit\"\u003eSave\u003c/button\u003e\n     \u003c/form\u003e\n \n         \n     \u003c/div\u003e\n \n \u003c/div\u003e\n\nGreat, the views are done. Now let's add some logic in our AdminController. Go ahead and open the AdminController.cs in the Controllers directory and add the following code.\n\n     public IActionResult Edit(int id)\n        {\n            var guest = _dbContext.Guests.FirstOrDefault(x =\u003e x.Id == id);\n            return View(guest);\n        }\n\n        [HttpPost]\n        public IActionResult Edit([FromForm] int id, string name, string code, bool? isAttending, EMealType mealType, string comments)\n        {\n              var guest = _dbContext.Guests.FirstOrDefault(x =\u003e x.Id == id);\n              guest.Name = name;\n              guest.Code = code;\n              if (isAttending != null)\n              {\n                    guest.IsAttending = (bool)isAttending;\n              }\n              guest.MealType = mealType;\n              guest.Comments = comments;\n              guest.HasResponded = true;\n\n              _dbContext.Guests.Update(guest);\n              _dbContext.SaveChanges();\n\n             return View(\"Index\",_dbContext.Guests.ToList());\n        }\n\nGreat. Now let's test this the application by executing dotnet run and see if the edit functionality is working as intended.\n\n**8) Authentication**\n\nNow we have all this great functionality, but we're not there yet. Everyone can now navigate to the /admin page and manage all your guests. This is of course not secure.\n\nGo ahead and add the following line of code on top of the AdminController class within the AdminController.cs file.\n\n    [Authorize]\n\nNow run the application and navigate to http://localhost:5000/Admin and you'll see you now require a username \u0026 password to login.\n\nNavigate to http://localhost:5000/Account/Register to create an account and see if you're able to login afterwards.\n\nTo disable registration remove the relevant methods in the AccountController.cs file within the Controllers directory.\n\n**Congratulations, you now have a fully functional ASP.NET Core web application with a working database \u0026 working authentication**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frootdevelop%2Fmywedding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frootdevelop%2Fmywedding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frootdevelop%2Fmywedding/lists"}