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

Implementation of ticket comments feature #4

Open
wants to merge 1 commit into
base: master
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
34 changes: 34 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
// 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
"version": "0.2.0",
"configurations": [
{
"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}/src/src/bin/Debug/netcoreapp2.0/src.dll",
"args": [],
"cwd": "${workspaceFolder}/src/src",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
36 changes: 36 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/src/src.csproj"
],
"problemMatcher": "$tsc"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/src/src.csproj"
],
"problemMatcher": "$tsc"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/src/src/src.csproj"
],
"problemMatcher": "$tsc"
}
]
}
40 changes: 40 additions & 0 deletions src/src/Controllers/Api/TicketController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,46 @@ public async Task<IActionResult> DeleteTicketCustomer([FromRoute] Guid id)

}

[HttpPost("PostTicketComment")]
public async Task<IActionResult> PostTicketComment([FromBody] TicketThread ticketThread)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
try
{
if(ticketThread.ticketId == Guid.Empty)
{
return NotFound();
}

if(ticketThread.ticketThreadId == Guid.Empty)
{
ticketThread.ticketThreadId = new Guid();
_context.TicketThread.Add(ticketThread);
await _context.SaveChangesAsync();

return Json(new { success = true, message = "Add new data success." });
}

else
{
return Json(new { success = false, message = "Comment already exists" });
}
}
catch (Exception ex)
{
return Json(new { success = false, message = ex.Message });
}
}

[HttpGet("ShowTicketComments/{ticketId}")]
public IActionResult ShowTicketComments([FromRoute]Guid ticketId)
{
return Json(new { data = _context.TicketThread.Where(x => x.ticketId.Equals(ticketId)).ToList() });
}

private bool TicketExists(Guid id)
{
return _context.Ticket.Any(e => e.ticketId == id);
Expand Down
42 changes: 42 additions & 0 deletions src/src/Controllers/TicketController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public IActionResult AddEdit(Guid org, Guid id)
if (id == Guid.Empty)
{
Ticket ticket = new Ticket();
ticket.CreateBy = _userManager.GetUserName(User);
ticket.organizationId = org;

IList<Product> products = _context.Product.Where(x => x.organizationId.Equals(org)).ToList();
Expand Down Expand Up @@ -116,5 +117,46 @@ public IActionResult AddEditCustomerTicket(Guid cust, Guid id)
}

}

public IActionResult Detail(Guid ticketId)
{
if(ticketId == Guid.Empty)
{
return NotFound();
}
Ticket ticket = _context.Ticket.Where(x => x.ticketId.Equals(ticketId)).FirstOrDefault();
Product product = _context.Product.Where(x => x.productId.Equals(ticket.productId)).FirstOrDefault();
SupportAgent agent = _context.SupportAgent.Where(x => x.supportAgentId.Equals(ticket.supportAgentId)).FirstOrDefault();
SupportEngineer engineer = _context.SupportEngineer.Where(x => x.supportEngineerId.Equals(ticket.supportEngineerId)).FirstOrDefault();
Contact contact = _context.Contact.Where(x => x.contactId.Equals(ticket.contactId)).FirstOrDefault();
ViewData["ticket"] = ticket.ticketId;
ViewBag.productName = product.productName;
ViewBag.supportAgentName = agent.supportAgentName;
ViewBag.supportEngineerName = engineer.supportEngineerName;
ViewBag.contactName = contact.contactName;
return View(ticket);
}

public IActionResult AddComment(Guid ticketId)
{
if(ticketId == Guid.Empty)
{
return NotFound();
}
TicketThread ticketThread = new TicketThread();
ticketThread.ticketId = ticketId;
ticketThread.CreateBy = _userManager.GetUserName(User);
return View(ticketThread);
}

public IActionResult ShowComments(Guid ticketId)
{
if(ticketId == Guid.Empty)
{
return NotFound();
}
TicketThread ticketThread = _context.TicketThread.Where(x => x.ticketId.Equals(ticketId)).FirstOrDefault();
return View(ticketThread);
}
}
}
2 changes: 2 additions & 0 deletions src/src/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ protected override void OnModelCreating(ModelBuilder builder)

public DbSet<src.Models.Ticket> Ticket { get; set; }

public DbSet<src.Models.TicketThread> TicketThread { get; set; }

public DbSet<src.Models.ApplicationUser> ApplicationUser { get; set; }
}
}
Loading