This commit is contained in:
kuchy 2022-05-10 16:41:44 +02:00
parent 1a44913e4f
commit 406cb6ae6f
320 changed files with 32422 additions and 17 deletions

35
EGUI/lab2/lab2/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,35 @@
{
"version": "0.2.0",
"configurations": [
{
// 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
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net6.0/lab2.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

41
EGUI/lab2/lab2/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/lab2.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/lab2.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/lab2.csproj"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Encodings.Web;
namespace lab2.Controllers
{
public class BlogViewController : Controller
{
//
// GET: /Register/
public IActionResult Index()
{
return View();
}
//
// GET: /Register/RegisterUser/?userid=Rick&email=4&password=test&blogid=blogtest
public IActionResult RegisterUser(string userid, string email, string password, string blogid)
{
ViewData["userid"] = "userid: " + userid;
ViewData["email"] = "email: " + email;
ViewData["password"] = "password: " + password;
ViewData["blogid"] = "blogid: " + blogid;
return View();
}
}
}

View File

@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Encodings.Web;
namespace lab2.Controllers
{
public class LoginController : Controller
{
//
// GET: /Login/
public IActionResult Index()
{
return View();
}
//
// GET: /Login/LoginUser/
// https://localhost:{PORT}/Login/LoginUser/?userid=Rick&password=4
public IActionResult LoginUser(string userid, string password)
{
ViewData["userid"] = "userid: " + userid;
ViewData["password"] = "password: " + password;
return View();
}
}
}

View File

@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Encodings.Web;
namespace lab2.Controllers
{
public class RegisterController : Controller
{
//
// GET: /Register/
public IActionResult Index()
{
return View();
}
//
// GET: /Register/RegisterUser/?userid=Rick&email=4&password=test&blogid=blogtest
public IActionResult RegisterUser(string userid, string email, string password, string blogid)
{
ViewData["userid"] = "userid: " + userid;
ViewData["email"] = "email: " + email;
ViewData["password"] = "password: " + password;
ViewData["blogid"] = "blogid: " + blogid;
return View();
}
}
}

View File

@ -0,0 +1,153 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using lab2.Models;
namespace lab2.Controllers
{
public class UserController : Controller
{
private readonly lab2UserContext _context;
public UserController(lab2UserContext context)
{
_context = context;
}
// GET: User
public async Task<IActionResult> Index()
{
return View(await _context.User.ToListAsync());
}
// GET: User/Details/5
public async Task<IActionResult> Details(string id)
{
if (id == null)
{
return NotFound();
}
var user = await _context.User
.FirstOrDefaultAsync(m => m.Id == id);
if (user == null)
{
return NotFound();
}
return View(user);
}
// GET: User/Create
public IActionResult Create()
{
return View();
}
// POST: User/Create
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,email,password")] User user)
{
if (ModelState.IsValid)
{
_context.Add(user);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(user);
}
// GET: User/Edit/5
public async Task<IActionResult> Edit(string id)
{
if (id == null)
{
return NotFound();
}
var user = await _context.User.FindAsync(id);
if (user == null)
{
return NotFound();
}
return View(user);
}
// POST: User/Edit/5
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(string id, [Bind("Id,email,password")] User user)
{
if (id != user.Id)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(user);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!UserExists(user.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(user);
}
// GET: User/Delete/5
public async Task<IActionResult> Delete(string id)
{
if (id == null)
{
return NotFound();
}
var user = await _context.User
.FirstOrDefaultAsync(m => m.Id == id);
if (user == null)
{
return NotFound();
}
return View(user);
}
// POST: User/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string id)
{
var user = await _context.User.FindAsync(id);
_context.User.Remove(user);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
private bool UserExists(string id)
{
return _context.User.Any(e => e.Id == id);
}
}
}

View File

@ -0,0 +1,17 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using lab2.Models;
public class lab2UserContext : DbContext
{
public lab2UserContext (DbContextOptions<lab2UserContext> options)
: base(options)
{
}
public DbSet<lab2.Models.User> User { get; set; }
}

View File

@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
namespace lab2.Models
{
public class Blog
{
public string? Id { get; set; }
public string? Title { get; set; }
public string? OwnerId { get; set; }
public BlogEntry[]? Entries {get; set; }
}
}

View File

@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace lab2.Models
{
public class BlogEntry
{
public string? Title { get; set; }
[DataType(DataType.Date)]
public DateTime datetime { get; set; }
public string? content {get; set; }
}
}

View File

@ -0,0 +1,11 @@
using System.ComponentModel.DataAnnotations;
namespace lab2.Models
{
public class User
{
public string? Id { get; set; }
public string? email { get; set; }
public string? password { get; set; }
}
}

View File

@ -1,4 +1,9 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<lab2UserContext>(options =>
options.UseSqlite(builder.Configuration.GetConnectionString("lab2UserContext") ?? throw new InvalidOperationException("Connection string 'lab2UserContext' not found.")));
// Add services to the container.
builder.Services.AddControllersWithViews();

View File

@ -0,0 +1,5 @@
@{
ViewData["Title"] = "Blog View";
}
<h2>Blog View</h2>

View File

@ -0,0 +1,7 @@
@{
ViewData["Title"] = "Login";
}
<h2>Login</h2>
<p>Hello from our Login Template!</p>

View File

@ -0,0 +1,10 @@
@{
ViewData["Title"] = "Logged User";
}
<h2>Welcome</h2>
<ul>
<li>@ViewData["userid"]</li>
<li>@ViewData["password"]</li>
</ul>

View File

@ -0,0 +1,7 @@
@{
ViewData["Title"] = "Register";
}
<h2>Register</h2>
<p>Hello from our Register Template!</p>

View File

@ -0,0 +1,12 @@
@{
ViewData["Title"] = "Register User";
}
<h2>Welcome</h2>
<ul>
<li>@ViewData["userid"]</li>
<li>@ViewData["email"]</li>
<li>@ViewData["password"]</li>
<li>@ViewData["blogid"]</li>
</ul>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - lab2</title>
<title>@ViewData["Title"] - Blog App</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/lab2.styles.css" asp-append-version="true" />
@ -12,7 +12,7 @@
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">lab2</a>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Blog App</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -38,7 +38,7 @@
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2022 - lab2 - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
&copy; 2022 - Blog App - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>

View File

@ -0,0 +1,43 @@
@model lab2.Models.User
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>User</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Id" class="control-label"></label>
<input asp-for="Id" class="form-control" />
<span asp-validation-for="Id" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="email" class="control-label"></label>
<input asp-for="email" class="form-control" />
<span asp-validation-for="email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="password" class="control-label"></label>
<input asp-for="password" class="form-control" />
<span asp-validation-for="password" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,33 @@
@model lab2.Models.User
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>User</h4>
<hr />
<dl class="row">
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.email)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.email)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.password)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.password)
</dd>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-action="Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,30 @@
@model lab2.Models.User
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>User</h4>
<hr />
<dl class="row">
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.email)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.email)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.password)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.password)
</dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model?.Id">Edit</a> |
<a asp-action="Index">Back to List</a>
</div>

View File

@ -0,0 +1,39 @@
@model lab2.Models.User
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>User</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="email" class="control-label"></label>
<input asp-for="email" class="form-control" />
<span asp-validation-for="email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="password" class="control-label"></label>
<input asp-for="password" class="form-control" />
<span asp-validation-for="password" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,41 @@
@model IEnumerable<lab2.Models.User>
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.email)
</th>
<th>
@Html.DisplayNameFor(model => model.password)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.email)
</td>
<td>
@Html.DisplayFor(modelItem => item.password)
</td>
<td>
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -1,9 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"lab2UserContext": "Data Source=lab2UserContext-85435385-56ab-4666-ad5b-1892b82e95b9.db"
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"lab2UserContext": "Data Source=lab2UserContext-85435385-56ab-4666-ad5b-1892b82e95b9.db"
}
}

Some files were not shown because too many files have changed in this diff Show More