Skip to content

Commit 3a35eb7

Browse files
Merge pull request #14 from chenxidev1129/11-change-task-to-ticket
Convert Task to Ticket
2 parents a789bbd + 39c07d0 commit 3a35eb7

23 files changed

+307
-310
lines changed

taskmaster-api/Controllers/TaskController.cs

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Mvc;
3+
using taskmaster_api.Data.DTOs;
4+
using taskmaster_api.Services.Interface;
5+
6+
namespace taskmaster_api.Controllers
7+
{
8+
[Route("api/[controller]")]
9+
[ApiController]
10+
[Authorize]
11+
public class TicketController : ApplicationControllerBase
12+
{
13+
private readonly ITicketService _ticketService;
14+
15+
public TicketController(ITicketService ticketService)
16+
{
17+
_ticketService = ticketService;
18+
}
19+
20+
[HttpGet]
21+
public IActionResult GetAllTickets()
22+
{
23+
return ToHttpResult<List<TicketDto>>(_ticketService.GetAllTickets());
24+
}
25+
26+
[HttpGet("{id}")]
27+
public IActionResult GetTicket(int id)
28+
{
29+
return ToHttpResult<TicketDto>(_ticketService.GetTicketById(id));
30+
}
31+
32+
[HttpPost]
33+
public IActionResult CreateTicket(TicketDto ticketDto)
34+
{
35+
return ToHttpResult<TicketDto>(_ticketService.CreateTicket(ticketDto));
36+
}
37+
38+
[HttpPut("{id}")]
39+
public IActionResult UpdateTicket(int id, TicketDto ticketDto)
40+
{
41+
return ToHttpResult<TicketDto>(_ticketService.UpdateTicket(id, ticketDto));
42+
}
43+
44+
[HttpDelete("{id}")]
45+
public IActionResult DeleteTicket(int id)
46+
{
47+
return ToHttpResult(_ticketService.DeleteTicket(id));
48+
}
49+
}
50+
}

taskmaster-api/Data/Contexts/ApplicationDbContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public ApplicationDbContext(DbContextOptions options) : base(options)
1111
{
1212
}
1313

14-
public virtual DbSet<TaskEntity> Tasks { get; set; }
14+
public virtual DbSet<TicketEntity> Tickets { get; set; }
1515
public virtual DbSet<CommentEntity> Comments { get; set; }
1616
public virtual DbSet<AttachmentEntity> Attachments { get; set; }
1717
public virtual DbSet<TagEntity> Tags { get; set; }

taskmaster-api/Data/DTOs/AttachmentDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class AttachmentDto : IDto<AttachmentEntity>
88
{
99
public int? Id { get; set; }
1010
public string UserId { get; set; }
11-
public int TaskId { get; set; }
11+
public int TicketId { get; set; }
1212
public string FileName { get; set; }
1313
public DateTime CreatedAt { get; set; }
1414
public DateTime UpdatedAt { get; set; }

taskmaster-api/Data/DTOs/CommentDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class CommentDto : IDto<CommentEntity>
88
{
99
public int? Id { get; set; }
1010
public string UserId { get; set; }
11-
public int TaskId { get; set; }
11+
public int TicketId { get; set; }
1212
public string Content { get; set; }
1313
public DateTime CreatedAt { get; set; }
1414
public DateTime UpdatedAt { get; set; }

taskmaster-api/Data/DTOs/TaskDto.cs renamed to taskmaster-api/Data/DTOs/TicketDto.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace taskmaster_api.Data.DTOs
66
{
7-
public class TaskDto : IDto<TaskEntity>
7+
public class TicketDto : IDto<TicketEntity>
88
{
99
public int? Id { get; set; }
1010
public string Title { get; set; }
@@ -14,9 +14,9 @@ public class TaskDto : IDto<TaskEntity>
1414
public DateTime CreatedAt { get; set; }
1515
public DateTime UpdatedAt { get; set; }
1616

17-
public TaskDto()
17+
public TicketDto()
1818
{
19-
Status = Models.TaskStatus.Pending;
19+
Status = Models.TicketStatus.Pending;
2020
if (Id.HasValue)
2121
{
2222
UpdatedAt = DateTime.UtcNow;
@@ -28,9 +28,9 @@ public TaskDto()
2828
}
2929
}
3030

31-
public TaskEntity ToEntity()
31+
public TicketEntity ToEntity()
3232
{
33-
return EntityHelpers.ToEntity<TaskDto, TaskEntity>(this);
33+
return EntityHelpers.ToEntity<TicketDto, TicketEntity>(this);
3434
}
3535
}
3636
}

taskmaster-api/Data/Entities/AttachmentEntity.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public class AttachmentEntity : IEntity<AttachmentDto>
1818
public IdentityUser User { get; set; }
1919

2020
[Required]
21-
public int TaskId { get; set; }
22-
public TaskEntity Task { get; set; }
21+
public int TicketId { get; set; }
22+
public TicketEntity Ticket { get; set; }
2323

2424
[Required]
2525
[StringLength(255)]

taskmaster-api/Data/Entities/CommentEntity.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public class CommentEntity : IEntity<CommentDto>
1818
public IdentityUser User { get; set; }
1919

2020
[Required]
21-
public int TaskId { get; set; }
22-
public TaskEntity Task { get; set; }
21+
public int TicketId { get; set; }
22+
public TicketEntity Ticket { get; set; }
2323

2424
[Required]
2525
public string Content { get; set; }

taskmaster-api/Data/Entities/TaskEntity.cs renamed to taskmaster-api/Data/Entities/TicketEntity.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace taskmaster_api.Data.Entities
99
{
10-
public class TaskEntity : IEntity<TaskDto>
10+
public class TicketEntity : IEntity<TicketDto>
1111
{
1212
[Key]
1313
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@@ -30,9 +30,9 @@ public class TaskEntity : IEntity<TaskDto>
3030
[Required]
3131
public DateTime UpdatedAt { get; set; }
3232

33-
public TaskDto ToDto()
33+
public TicketDto ToDto()
3434
{
35-
return EntityHelpers.ToDto<TaskEntity, TaskDto>(this);
35+
return EntityHelpers.ToDto<TicketEntity, TicketDto>(this);
3636
}
3737
}
3838
}

taskmaster-api/Data/Models/TaskStatus.cs renamed to taskmaster-api/Data/Models/TicketStatus.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace taskmaster_api.Data.Models
22
{
3-
public static class TaskStatus
3+
public static class TicketStatus
44
{
55
public const string Pending = "Pending";
66
public const string Open = "Open";

0 commit comments

Comments
 (0)