Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Binary file added Csharp3-main/localdb.db
Binary file not shown.
12 changes: 6 additions & 6 deletions ToDoList/ToDoList.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToDoList.Test", "tests\ToDo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToDoList.Persistence", "src\ToDoList.Persistence\ToDoList.Persistence.csproj", "{9D93325A-6242-4417-AF1B-7B06DB3A7864}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToDoList.Frontend", "src\ToDoList.Frontend\ToDoList.Frontend.csproj", "{2A4A356C-0F7A-476E-88C9-E101784C9F30}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToDoList.Frontend", "src\ToDoList.Frontend\ToDoList.Frontend.csproj", "{04CA31F5-49D8-4978-B917-98D3B10CD156}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -42,16 +42,16 @@ Global
{9D93325A-6242-4417-AF1B-7B06DB3A7864}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D93325A-6242-4417-AF1B-7B06DB3A7864}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D93325A-6242-4417-AF1B-7B06DB3A7864}.Release|Any CPU.Build.0 = Release|Any CPU
{2A4A356C-0F7A-476E-88C9-E101784C9F30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A4A356C-0F7A-476E-88C9-E101784C9F30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A4A356C-0F7A-476E-88C9-E101784C9F30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A4A356C-0F7A-476E-88C9-E101784C9F30}.Release|Any CPU.Build.0 = Release|Any CPU
{04CA31F5-49D8-4978-B917-98D3B10CD156}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04CA31F5-49D8-4978-B917-98D3B10CD156}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04CA31F5-49D8-4978-B917-98D3B10CD156}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04CA31F5-49D8-4978-B917-98D3B10CD156}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D8E3A966-671F-4E7C-86BD-B51066E39B67} = {36FD4317-29CD-4B7B-AA95-92F1582DEC01}
{61CAF0A1-2EBB-410B-BB40-DA9590E88664} = {36FD4317-29CD-4B7B-AA95-92F1582DEC01}
{EEB409BA-8B59-4C14-84D3-301E75F542C4} = {D78FC9D1-46B7-4F93-AE9A-24719D8C82D2}
{9D93325A-6242-4417-AF1B-7B06DB3A7864} = {36FD4317-29CD-4B7B-AA95-92F1582DEC01}
{2A4A356C-0F7A-476E-88C9-E101784C9F30} = {36FD4317-29CD-4B7B-AA95-92F1582DEC01}
{04CA31F5-49D8-4978-B917-98D3B10CD156} = {36FD4317-29CD-4B7B-AA95-92F1582DEC01}
EndGlobalSection
EndGlobal
Binary file modified ToDoList/data/localdb.db
Binary file not shown.
4 changes: 2 additions & 2 deletions ToDoList/src/ToDoList.Domain/DTOs/ToDoItemCreateRequestDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace ToDoList.Domain.DTOs;

using ToDoList.Domain.Models;

public record ToDoItemCreateRequestDto(string Name, string Description, bool IsCompleted) //id is generated
public record ToDoItemCreateRequestDto(string Name, string Description, bool IsCompleted, string? Category) //id is generated
{
public ToDoItem ToDomain() => new() { Name = Name, Description = Description, IsCompleted = IsCompleted };
public ToDoItem ToDomain() => new() { Name = Name, Description = Description, IsCompleted = IsCompleted, Category = Category };
}
4 changes: 2 additions & 2 deletions ToDoList/src/ToDoList.Domain/DTOs/ToDoItemGetResponseDto.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace ToDoList.Domain.DTOs;
using ToDoList.Domain.Models;

public record class ToDoItemGetResponseDto(int Id, string Name, string Description, bool IsCompleted) //let client know the Id
public record class ToDoItemGetResponseDto(int Id, string Name, string Description, bool IsCompleted, string? Category) //let client know the Id
{
public static ToDoItemGetResponseDto FromDomain(ToDoItem item) => new(item.ToDoItemId, item.Name, item.Description, item.IsCompleted);
public static ToDoItemGetResponseDto FromDomain(ToDoItem item) => new(item.ToDoItemId, item.Name, item.Description, item.IsCompleted, item.Category);
}
4 changes: 2 additions & 2 deletions ToDoList/src/ToDoList.Domain/DTOs/ToDoItemUpdateRequestDto.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace ToDoList.Domain.DTOs;
using ToDoList.Domain.Models;

public record class ToDoItemUpdateRequestDto(string Name, string Description, bool IsCompleted)
public record class ToDoItemUpdateRequestDto(string Name, string Description, bool IsCompleted, string? Category)
{
public ToDoItem ToDomain() => new() { Name = this.Name, Description = this.Description, IsCompleted = this.IsCompleted };
public ToDoItem ToDomain() => new() { Name = this.Name, Description = this.Description, IsCompleted = this.IsCompleted, Category = this.Category };
}
2 changes: 2 additions & 0 deletions ToDoList/src/ToDoList.Domain/Models/ToDoItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public class ToDoItem
[StringLength(250)]
public string Description { get; set; }
public bool IsCompleted { get; set; }

public string? Category { get; set; }
}
12 changes: 12 additions & 0 deletions ToDoList/src/ToDoList.Frontend/Components/AhojSvete.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@page "/AhojSvete"

<PageTitle>Ahoj svete</PageTitle>

<h1>@ahojSvete</h1>

Vítej v moji aplikaci.

@code
{
string ahojSvete = "Ahoj světe přes c# z jiné stránky!";
}
12 changes: 0 additions & 12 deletions ToDoList/src/ToDoList.Frontend/Components/Pages/AhojSvete.razor

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
@page "/mujDashboard"
@rendermode InteractiveServer

<h1>DashBoard</h1>
<!--@((MarkupString)GenerateTable())-->
<table>
<thead>
<tr>
<th>
ID Seřadit
<button @onclick="OrderById">@((isSortedByIdAscending ? "Od nejvyššího" : "Od nejnižšího"))</button>
</th>
<th>
Name Seřadit
<button @onclick="OrderByName">@((isSortedByNameAscending ? "Z-A" : "A-Z"))</button>
</th>
</tr>
</thead>
<tbody>

@foreach (var todoItem in toDoItems)
{
<tr>
<td>@todoItem.ToDoItemId</td>
<td>@todoItem.Name</td>
</tr>
}
</tbody>
</table>

@code {
/* public string GenerateTable()
{
var html = new System.Text.StringBuilder();
html.Append("<table>");
foreach (var todoitem in toDoItems)
{
html.Append("<tr>");
html.Append($"<td>{todoitem.ToDoItemId}</td>");
html.Append($"<td>{todoitem.Name}</td>");
html.Append("</tr>");
}
html.Append("</table>");
return html.ToString();
}*/
private List<ToDoItemView> toDoItems = new List<ToDoItemView>
{
new ToDoItemView { ToDoItemId = 1, Name = "Udělat úkol na Czechitas", IsCompleted = false },
new ToDoItemView { ToDoItemId = 2, Name = "Udělat nepovinný úkol na Czechitas", IsCompleted = false }
};

private bool isSortedByIdAscending = true;
private bool isSortedByNameAscending = true;

private void OrderById()
{
if (isSortedByIdAscending)
toDoItems = toDoItems.OrderByDescending(item => item.ToDoItemId).ToList();
else
toDoItems = toDoItems.OrderBy(item => item.ToDoItemId).ToList();

isSortedByIdAscending = !isSortedByIdAscending;
}

private void OrderByName()
{
if (isSortedByNameAscending)
toDoItems = toDoItems.OrderByDescending(item => item.Name).ToList();
else
toDoItems = toDoItems.OrderBy(item => item.Name).ToList();

isSortedByNameAscending = !isSortedByNameAscending;
}

public class ToDoItemView
{
public int ToDoItemId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsCompleted { get; set; }
}
}
48 changes: 48 additions & 0 deletions ToDoList/src/ToDoList.Frontend/Components/Pages/DashBoard.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@using ToDoList.Frontend.Views
@using ToDoList.Frontend.Clients
@inject IToDoItemsClient ToDoItemsClient
@rendermode InteractiveServer

<h1>Dashboard</h1>

<table>
<tr>
<td><button @onclick="OrderById">Seradit Podle Id</button></td>
<td><button @onclick="OrderByName">Seradit Podle Jmena</button></td>
<td></td>
<td></td>
</tr>
@if(toDoItems!=null)
{

}
@foreach(var toDoItem in toDoItems)
{
<tr>
<td>@toDoItem.ToDoItemId</td>
<td>@toDoItem.Name</td>
<td>@toDoItem.Description</td>
<td>@toDoItem.IsCompleted</td>
</tr>
}
</table>


@code
{
protected override async Task OnInitializedAsync()
{
toDoItems = await ToDoItemsClient.ReadItemsAsync();
}
private List<ToDoItemView>? toDoItems = [];

public void OrderByName()
{
toDoItems = toDoItems?.OrderBy(x => x.Name).ToList();
}

public void OrderById()
{
toDoItems = toDoItems?.OrderBy(x => x.ToDoItemId).ToList();
}
}
50 changes: 39 additions & 11 deletions ToDoList/src/ToDoList.Frontend/Components/Pages/Home.razor
Original file line number Diff line number Diff line change
@@ -1,27 +1,55 @@
@page "/"
@rendermode InteractiveServer
<PageTitle>Domovska stranka</PageTitle>

<PageTitle>Home</PageTitle>
<DashBoard/>

<Dashboard />
<!--<h1>@AhojSvete()</h1>

<h1>@ahojSvete</h1>

Vítej v mojí aplikaci.
Vítej v moji aplikaci.
<br>
<button @onclick="Increment">Moje tlačítko</button>

<button @onclick="Increment"> Moje tlačítko</button>
<br>
Hodnota počítadla: @counter;

Hodnota počítadla: @counter

<h2> Tohle je nadpis druhe urovne</h2>
<p> Tohle je odstavec <br> se zalomenym textem</p>
@VypisCisla1Az10();


<ul>
<li> polozka 1 </li>
<li> polozka 2</li>
</ul>
<ol>
<li>První položka</li>
<li>Druhá položka</li>
<li>Třetí položka</li>
</ol>
@code
{
string ahojSvete = "Ahoj světe ještě jednou!";

int counter = 0;

public void Increment()
{
counter++;
}

string ahojSvete = "Ahoj světe přes c#!";

public string AhojSvete()
{
return "Ahoj světe přes c# z metody";
}

public string VypisCisla1Az10()
{
string vypis = "";
for (int i = 1; i < 10; i++)
{
vypis += i;
}
return vypis;
}-->

}
7 changes: 5 additions & 2 deletions ToDoList/src/ToDoList.Frontend/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
.AddInteractiveServerComponents();

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5000") });
builder.Services.AddScoped<IToDoItemsClient, ToDoItemsClient>();

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5000") });
builder.Services.AddScoped<IToDoItemsClient, ToDoItemsClient>();
Expand All @@ -26,6 +29,6 @@
app.UseAntiforgery();

app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
.AddInteractiveServerRenderMode();

app.Run();

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ToDoList.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddCategoryToToDoItem : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Category",
table: "ToDoItems",
type: "TEXT",
nullable: true);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Category",
table: "ToDoItems");
}
}
}
Loading