Skip to content

Commit

Permalink
feat: created CRUD backend for Ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
isala404 committed Dec 6, 2021
1 parent ea50ced commit 7cd179f
Show file tree
Hide file tree
Showing 31 changed files with 1,255 additions and 391 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# CS8618: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
dotnet_diagnostic.CS8618.severity = none
11 changes: 8 additions & 3 deletions WorkFlow.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlow.Server", "WorkFlow\Server\WorkFlow.Server.csproj", "{1FA80EF5-6858-4DB0-B12D-244A6B68F338}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkFlow.Server", "WorkFlow\Server\WorkFlow.Server.csproj", "{1FA80EF5-6858-4DB0-B12D-244A6B68F338}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlow.Client", "WorkFlow\Client\WorkFlow.Client.csproj", "{1646B20A-3476-459B-A4D5-C37AB0557549}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkFlow.Client", "WorkFlow\Client\WorkFlow.Client.csproj", "{1646B20A-3476-459B-A4D5-C37AB0557549}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlow.Shared", "WorkFlow\Shared\WorkFlow.Shared.csproj", "{3F17C59C-86DF-4895-87D3-173D609F40FA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkFlow.Shared", "WorkFlow\Shared\WorkFlow.Shared.csproj", "{3F17C59C-86DF-4895-87D3-173D609F40FA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9B378F77-0E25-4459-AE9B-8CE4C54B4DBB}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
7 changes: 7 additions & 0 deletions WorkFlow/Client/Pages/Authentication.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />

@code{
[Parameter] public string? Action { get; set; }
}
90 changes: 10 additions & 80 deletions WorkFlow/Client/Pages/Project/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,97 +16,27 @@
<h2 class="text-center text-2xl border-b-2 border-black">TO-DOs</h2>
<div>
<a href="@Company/project/@Project/ticket/1/manage">
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket />
</a>
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket />
<UserTicket />
<UserTicket />
<UserTicket />
</div>
</div>
<div class="bg-yellow-100 border-2 border-black" style="width: 405px;">
<h2 class="text-center text-2xl border-b-2 border-black">In-Progress</h2>
<div>
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket />
<UserTicket />
<UserTicket />
</div>
</div>
<div class="bg-green-200 border-2 border-black" style="width: 405px;">
<h2 class="text-center text-2xl border-b-2 border-black">Completed</h2>
<div>
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket
Name="Create Something Something"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tinciduLorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et sapien pulvinar ante pellentesque lacinia. Etiam tincidunt sed...."
Priority="2"
Assignee="Isala Piyarisi"
DueDate=@DateTime.Parse("03/11/2021")
EstimatedTime=@TimeSpan.Parse("02:00:00")
/>
<UserTicket />
<UserTicket />
</div>
</div>
</div>
Expand Down
20 changes: 13 additions & 7 deletions WorkFlow/Client/Pages/Ticket/Create.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/{Company}/project/{project}/ticket/create"
@inject WorkFlow.Shared.Interfaces.ITicket TicketService

<div class="flex flex-grow flex-col bg-gray-100 p-5 md:w-4/5 xl:w-2/5 m-auto mt-20">
<h1 class="text-2xl text-center">Create a new ticket</h1>
Expand Down Expand Up @@ -27,10 +28,10 @@
</div>
<div class="mb-2">
<label for="assignee" class="text-grey-darker inline-block mb-2">Assignee</label>
<InputSelect @bind-Value="_ticket.Assignee" id="assignee" class="border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 bg-white" name="assignee" required>
<InputSelect @bind-Value="_ticket.Assignee.UserName" id="assignee" class="border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 bg-white" name="assignee" required>
@foreach (var user in _users)
{
<option value="@user.Name">@user.Name</option>
<option value="@user.UserName">@user.Name</option>
}
</InputSelect>
</div>
Expand Down Expand Up @@ -58,16 +59,21 @@

private readonly Ticket _ticket = new();

private void HandleValidSubmit()
private async void HandleValidSubmit()
{
Console.WriteLine($"Ticket Created: {_ticket.Name}, {_ticket.Description}, {_ticket.Priority}, {_ticket.Assignee}, {_ticket.DueDate}, {_ticket.EstimatedTime}");
var ticket = await TicketService.CreateTicket(_ticket);
Console.WriteLine($"Ticket Created: {ticket.Name}, {ticket.Description}, {ticket.Priority}, {ticket.Assignee}, {ticket.DueDate}, {ticket.EstimatedTime}");
}

private User[] _users = new[]
{
new User {Name = "John Doe"},
new User {Name = "Jane Doe"},
new User {Name = "John Smith"},
new User {Name = "John Doe", UserName="john"},
new User {Name = "Jane Doe", UserName="jane"},
new User {Name = "John Smith", UserName="john2"},
};

protected override void OnInitialized()
{
_ticket.Assignee = _users[0];
}
}
15 changes: 10 additions & 5 deletions WorkFlow/Client/Pages/Ticket/Manage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
</div>
<div class="mb-2">
<label for="assignee" class="text-grey-darker inline-block mb-2">Assignee</label>
<InputSelect @bind-Value="_ticket.Assignee" id="assignee" class="border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 bg-white" name="assignee" required>
<InputSelect @bind-Value="_ticket.Assignee.UserName" id="assignee" class="border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 bg-white" name="assignee" required>
@foreach (var user in _users)
{
<option value="@user.Name">@user.Name</option>
<option value="@user.UserName">@user.Name</option>
}
</InputSelect>
</div>
Expand Down Expand Up @@ -71,13 +71,18 @@

private User[] _users = new[]
{
new User {Name = "John Doe"},
new User {Name = "Jane Doe"},
new User {Name = "John Smith"},
new User {Name = "John Doe", UserName="john"},
new User {Name = "Jane Doe", UserName="jane"},
new User {Name = "John Smith", UserName="john2"},
};

private void DeleteTicket()
{
Console.WriteLine($"Ticket Deleted: {_ticket.Name}, {_ticket.Description}, {_ticket.Priority}, {_ticket.Assignee}, {_ticket.DueDate}, {_ticket.EstimatedTime}");
}

protected override void OnInitialized()
{
_ticket.Assignee = _users[0];
}
}
2 changes: 2 additions & 0 deletions WorkFlow/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using WorkFlow.Client;
using WorkFlow.Client.Services;
using WorkFlow.Shared.Interfaces;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
Expand All @@ -15,6 +16,7 @@
builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient("WorkFlow.ServerAPI"));

builder.Services.AddScoped<INavService, NavService>();
builder.Services.AddScoped<ITicket, TicketService>();
builder.Services.AddApiAuthorization();

await builder.Build().RunAsync();
57 changes: 57 additions & 0 deletions WorkFlow/Client/Services/TicketService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
using WorkFlow.Shared.Entities;
using WorkFlow.Shared.Interfaces;

namespace WorkFlow.Client.Services
{
public class TicketService : ITicket
{
private readonly HttpClient _http;

public TicketService(HttpClient http)
{
_http = http;
}

public async Task<Ticket> CreateTicket(Ticket ticket)
{
var result = await _http.PostAsJsonAsync<Ticket>("api/ticket", ticket);
return await result.Content.ReadFromJsonAsync<Ticket>();
}

public async Task<bool> DeleteTicket(Guid ticketID)
{
throw new NotImplementedException();
}

public async Task<Ticket?> GetTicket(Guid ticketID)
{
throw new NotImplementedException();
}

public async Task<List<Ticket>> List(User user)
{
throw new NotImplementedException();
}

public async Task<List<Ticket>> ListTicketsByProject(Guid projectID)
{
throw new NotImplementedException();
}

public async Task<List<Ticket>> ListTicketsByUser(Guid userID)
{
throw new NotImplementedException();
}

public async Task<Ticket?> UpdateTicket(Guid ticketID, Ticket ticket)
{
throw new NotImplementedException();
}
}
}
Loading

0 comments on commit 7cd179f

Please sign in to comment.