Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Urgency label added to support request #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
4 changes: 3 additions & 1 deletion Controllers/SupportRequestController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using SupportApp.Models;
using SupportApp.Enums;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -15,13 +16,14 @@ public IActionResult Index()
}

[HttpPost]
public IActionResult AddRequest(string customerName, string description)
public IActionResult AddRequest(string customerName, string description, Urgency urgency)
{
var newRequest = new SupportRequest
{
Id = requests.Count + 1,
CustomerName = customerName,
Description = description,
Urgency = urgency,
IsResolved = false
};
requests.Insert(0, newRequest); // Insert at the beginning of the list
Expand Down
10 changes: 10 additions & 0 deletions Enums/Ugency.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace SupportApp.Enums
{
public enum Urgency
{
Low,
Medium,
High,
Apocolypse,
}
}
14 changes: 14 additions & 0 deletions Models/SupportRequest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using SupportApp.Enums;

namespace SupportApp.Models
{
public class SupportRequest
Expand All @@ -6,5 +8,17 @@ public class SupportRequest
public string CustomerName { get; set; } = string.Empty; // Initialize with default value
public string Description { get; set; } = string.Empty; // Initialize with default value
public bool IsResolved { get; set; } // Add this property
public Urgency Urgency { get; set; }
public string UrgencyIcon { get {
return Urgency switch
{
Urgency.Low => "🚩",
Urgency.Medium => "🚧",
Urgency.High => "🚨",
Urgency.Apocolypse => "🌋",
_ => "🚩",
};
}
}
}
}
5 changes: 3 additions & 2 deletions SupportRequestControllerTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using SupportApp.Controllers;
using SupportApp.Models;
using SupportApp.Enums;
using System.Collections.Generic;
using System.Linq;
using Xunit;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void AddRequest_AddsNewRequest_AndRedirectsToIndex()
string description = "Need help with product";

// Act
var result = controller.AddRequest(customerName, description);
var result = controller.AddRequest(customerName, description, Urgency.Low);

// Assert
var redirectToActionResult = Assert.IsType<RedirectToActionResult>(result);
Expand All @@ -46,7 +47,7 @@ public void ResolveRequest_ResolvesRequest_AndRedirectsToIndex()
{
// Arrange
var controller = new SupportRequestController();
controller.AddRequest("John Doe", "Need help with product");
controller.AddRequest("John Doe", "Need help with product", Urgency.Low);
int requestId = 1;

// Act
Expand Down
8 changes: 7 additions & 1 deletion Views/SupportRequest/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
<form id="addRequestForm">
<input type="text" name="customerName" placeholder="Customer Name" required />
<input type="text" name="description" placeholder="Description" required />
<select name="urgency" required>
<option value="Low">Low</option>
<option value="Medium">Medium</option>
<option value="High">High</option>
<option value="Apocolypse">Apocolypse</option>
</select>
<button type="submit">Add Request</button>
</form>
<ul id="requestList">
@foreach (var request in Model)
{
<li class="request-item" data-id="@request.Id">
<span>@request.CustomerName: @request.Description</span>
<span>@request.CustomerName: @request.Description @request.UrgencyIcon </span>
@if (!request.IsResolved)
{
<button class="resolve-button" data-id="@request.Id">Resolve</button>
Expand Down