Skip to content

Commit af3ac3e

Browse files
Merge pull request #9 from chenxidev1129/6-add-some-tables-for-task-management
6 add some tables for task management
2 parents 7f83107 + 9dc7cb4 commit af3ac3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2608
-36
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,7 @@ MigrationBackup/
360360
.ionide/
361361

362362
# Fody - auto-generated XML schema
363-
FodyWeavers.xsd
363+
FodyWeavers.xsd
364+
365+
# Upload foler
366+
taskmaster-api/Uploads/
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using taskmaster_api.Data.DTOs;
5+
using taskmaster_api.Services.Interface;
6+
7+
namespace taskmaster_api.Controllers
8+
{
9+
[Route("api/[controller]")]
10+
[ApiController]
11+
[Authorize]
12+
public class ActivityLogController : ApplicationControllerBase
13+
{
14+
private readonly IActivityLogService _activityLogService;
15+
16+
public ActivityLogController(IActivityLogService activityLogService)
17+
{
18+
_activityLogService = activityLogService;
19+
}
20+
21+
[HttpGet]
22+
public IActionResult GetAllActivityLogs()
23+
{
24+
return ToHttpResult<List<ActivityLogDto>>(_activityLogService.GetAllActivityLogs());
25+
}
26+
27+
[HttpGet("{id}")]
28+
public IActionResult GetActivityLog(int id)
29+
{
30+
return ToHttpResult<ActivityLogDto>(_activityLogService.GetActivityLogById(id));
31+
}
32+
33+
[HttpPost]
34+
public IActionResult CreateActivityLog(ActivityLogDto activityLogDto)
35+
{
36+
return ToHttpResult<ActivityLogDto>(_activityLogService.CreateActivityLog(activityLogDto));
37+
}
38+
39+
[HttpPut("{id}")]
40+
public IActionResult UpdateActivityLog(int id, ActivityLogDto activityLogDto)
41+
{
42+
return ToHttpResult<ActivityLogDto>(_activityLogService.UpdateActivityLog(id, activityLogDto));
43+
}
44+
45+
[HttpDelete("{id}")]
46+
public IActionResult DeleteActivityLog(int id)
47+
{
48+
return ToHttpResult(_activityLogService.DeleteActivityLog(id));
49+
}
50+
}
51+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using taskmaster_api.Data.DTOs;
5+
using taskmaster_api.Services.Interface;
6+
7+
namespace taskmaster_api.Controllers
8+
{
9+
[Route("api/[controller]")]
10+
[ApiController]
11+
[Authorize]
12+
public class AttachmentController : ApplicationControllerBase
13+
{
14+
private readonly IAttachmentService _attachmentService;
15+
16+
public AttachmentController(IAttachmentService attachmentService)
17+
{
18+
_attachmentService = attachmentService;
19+
}
20+
21+
[HttpGet]
22+
public IActionResult GetAllAttachments()
23+
{
24+
return ToHttpResult<List<AttachmentDto>>(_attachmentService.GetAllAttachments());
25+
}
26+
27+
[HttpGet("{id}")]
28+
public IActionResult GetAttachment(int id)
29+
{
30+
return ToHttpResult<AttachmentDto>(_attachmentService.GetAttachmentById(id));
31+
}
32+
33+
[HttpPost]
34+
public IActionResult CreateAttachment(AttachmentDto attachmentDto)
35+
{
36+
return ToHttpResult<AttachmentDto>(_attachmentService.CreateAttachment(attachmentDto));
37+
}
38+
39+
[HttpPut("{id}")]
40+
public IActionResult UpdateAttachment(int id, AttachmentDto attachmentDto)
41+
{
42+
return ToHttpResult<AttachmentDto>(_attachmentService.UpdateAttachment(id, attachmentDto));
43+
}
44+
45+
[HttpDelete("{id}")]
46+
public IActionResult DeleteAttachment(int id)
47+
{
48+
return ToHttpResult(_attachmentService.DeleteAttachment(id));
49+
}
50+
51+
[HttpPost("upload")]
52+
public IActionResult Upload([FromForm] AttachmentUploadRequest request)
53+
{
54+
return ToHttpResult(_attachmentService.UploadFile(request));
55+
}
56+
}
57+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Mvc;
3+
using taskmaster_api.Data.DTOs;
4+
using taskmaster_api.Services;
5+
using taskmaster_api.Services.Interface;
6+
7+
namespace taskmaster_api.Controllers
8+
{
9+
[Route("api/[controller]")]
10+
[ApiController]
11+
[Authorize]
12+
public class CommentController : ApplicationControllerBase
13+
{
14+
private readonly ICommentService _commentService;
15+
16+
public CommentController(ICommentService commentService)
17+
{
18+
_commentService = commentService;
19+
}
20+
21+
[HttpGet]
22+
public IActionResult GetAllComments()
23+
{
24+
return ToHttpResult<List<CommentDto>>(_commentService.GetAllComments());
25+
}
26+
27+
[HttpGet("{id}")]
28+
public IActionResult GetComment(int id)
29+
{
30+
return ToHttpResult<CommentDto>(_commentService.GetCommentById(id));
31+
}
32+
33+
[HttpPost]
34+
public IActionResult CreateComment(CommentDto commentDto)
35+
{
36+
return ToHttpResult<CommentDto>(_commentService.CreateComment(commentDto));
37+
}
38+
39+
[HttpPut("{id}")]
40+
public IActionResult UpdateComment(int id, CommentDto commentDto)
41+
{
42+
return ToHttpResult<CommentDto>(_commentService.UpdateComment(id, commentDto));
43+
}
44+
45+
[HttpDelete("{id}")]
46+
public IActionResult DeleteComment(int id)
47+
{
48+
return ToHttpResult(_commentService.DeleteComment(id));
49+
}
50+
}
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using taskmaster_api.Data.DTOs;
5+
using taskmaster_api.Services.Interface;
6+
7+
namespace taskmaster_api.Controllers
8+
{
9+
[Route("api/[controller]")]
10+
[ApiController]
11+
[Authorize]
12+
public class NotificationController : ApplicationControllerBase
13+
{
14+
private readonly INotificationService _notificationService;
15+
16+
public NotificationController(INotificationService notificationService)
17+
{
18+
_notificationService = notificationService;
19+
}
20+
21+
[HttpGet]
22+
public IActionResult GetAllNotifications()
23+
{
24+
return ToHttpResult<List<NotificationDto>>(_notificationService.GetAllNotifications());
25+
}
26+
27+
[HttpGet("{id}")]
28+
public IActionResult GetNotification(int id)
29+
{
30+
return ToHttpResult<NotificationDto>(_notificationService.GetNotificationById(id));
31+
}
32+
33+
[HttpPost]
34+
public IActionResult CreateNotification(NotificationDto notificationDto)
35+
{
36+
return ToHttpResult<NotificationDto>(_notificationService.CreateNotification(notificationDto));
37+
}
38+
39+
[HttpPut("{id}")]
40+
public IActionResult UpdateNotification(int id, NotificationDto notificationDto)
41+
{
42+
return ToHttpResult<NotificationDto>(_notificationService.UpdateNotification(id, notificationDto));
43+
}
44+
45+
[HttpDelete("{id}")]
46+
public IActionResult DeleteNotification(int id)
47+
{
48+
return ToHttpResult(_notificationService.DeleteNotification(id));
49+
}
50+
}
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using taskmaster_api.Data.DTOs;
5+
using taskmaster_api.Services.Interface;
6+
7+
namespace taskmaster_api.Controllers
8+
{
9+
[Route("api/[controller]")]
10+
[ApiController]
11+
[Authorize]
12+
public class SettingController : ApplicationControllerBase
13+
{
14+
private readonly ISettingService _settingService;
15+
16+
public SettingController(ISettingService settingService)
17+
{
18+
_settingService = settingService;
19+
}
20+
21+
[HttpGet]
22+
public IActionResult GetAllSettings()
23+
{
24+
return ToHttpResult<List<SettingDto>>(_settingService.GetAllSettings());
25+
}
26+
27+
[HttpGet("{id}")]
28+
public IActionResult GetSetting(int id)
29+
{
30+
return ToHttpResult<SettingDto>(_settingService.GetSettingById(id));
31+
}
32+
33+
[HttpPost]
34+
public IActionResult CreateSetting(SettingDto settingDto)
35+
{
36+
return ToHttpResult<SettingDto>(_settingService.CreateSetting(settingDto));
37+
}
38+
39+
[HttpPut("{id}")]
40+
public IActionResult UpdateSetting(int id, SettingDto settingDto)
41+
{
42+
return ToHttpResult<SettingDto>(_settingService.UpdateSetting(id, settingDto));
43+
}
44+
45+
[HttpDelete("{id}")]
46+
public IActionResult DeleteSetting(int id)
47+
{
48+
return ToHttpResult(_settingService.DeleteSetting(id));
49+
}
50+
}
51+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Microsoft.AspNetCore.Http;
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+
public class TagController : ApplicationControllerBase
11+
{
12+
private readonly ITagService _tagService;
13+
14+
public TagController(ITagService tagService)
15+
{
16+
_tagService = tagService;
17+
}
18+
19+
[HttpGet]
20+
public IActionResult GetAllTags()
21+
{
22+
return ToHttpResult<List<TagDto>>(_tagService.GetAllTags());
23+
}
24+
25+
[HttpGet("{id}")]
26+
public IActionResult GetTag(int id)
27+
{
28+
return ToHttpResult<TagDto>(_tagService.GetTagById(id));
29+
}
30+
31+
[HttpPost]
32+
public IActionResult CreateTag(TagDto tagDto)
33+
{
34+
return ToHttpResult<TagDto>(_tagService.CreateTag(tagDto));
35+
}
36+
37+
[HttpPut("{id}")]
38+
public IActionResult UpdateTag(int id, TagDto tagDto)
39+
{
40+
return ToHttpResult<TagDto>(_tagService.UpdateTag(id, tagDto));
41+
}
42+
43+
[HttpDelete("{id}")]
44+
public IActionResult DeleteTag(int id)
45+
{
46+
return ToHttpResult(_tagService.DeleteTag(id));
47+
}
48+
}
49+
}

taskmaster-api/Controllers/TaskController.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Microsoft.AspNetCore.Mvc;
33
using taskmaster_api.Data.DTOs;
44
using taskmaster_api.Data.Models;
5+
using taskmaster_api.Services;
56
using taskmaster_api.Services.Interface;
67

78
namespace taskmaster_api.Controllers
@@ -18,6 +19,12 @@ public TaskController(ITaskService taskService)
1819
_taskService = taskService;
1920
}
2021

22+
[HttpGet]
23+
public IActionResult GetAllTasks()
24+
{
25+
return ToHttpResult<List<TaskDto>>(_taskService.GetAllTasks());
26+
}
27+
2128
[HttpGet("{id}")]
2229
public IActionResult GetTask(int id)
2330
{

taskmaster-api/Data/Contexts/ApplicationDbContext.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
1+
using Microsoft.AspNetCore.Identity;
2+
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
23
using Microsoft.EntityFrameworkCore;
34
using taskmaster_api.Data.Entities;
45

@@ -11,5 +12,11 @@ public ApplicationDbContext(DbContextOptions options) : base(options)
1112
}
1213

1314
public virtual DbSet<TaskEntity> Tasks { get; set; }
15+
public virtual DbSet<CommentEntity> Comments { get; set; }
16+
public virtual DbSet<AttachmentEntity> Attachments { get; set; }
17+
public virtual DbSet<TagEntity> Tags { get; set; }
18+
public virtual DbSet<ActivityLogEntity> ActivityLogs { get; set; }
19+
public virtual DbSet<NotificationEntity> Notifications { get; set; }
20+
public virtual DbSet<SettingEntity> Settings { get; set; }
1421
}
1522
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using taskmaster_api.Data.DTOs.Interface;
2+
using taskmaster_api.Data.Entities;
3+
using taskmaster_api.Utilities;
4+
5+
namespace taskmaster_api.Data.DTOs
6+
{
7+
public class ActivityLogDto : IDto<ActivityLogEntity>
8+
{
9+
public int? Id { get; set; }
10+
public string UserId { get; set; }
11+
public string Action { get; set; }
12+
public DateTime CreatedAt { get; set; }
13+
14+
public ActivityLogDto()
15+
{
16+
if (!Id.HasValue)
17+
{
18+
CreatedAt = DateTime.UtcNow;
19+
}
20+
}
21+
22+
public ActivityLogEntity ToEntity()
23+
{
24+
return EntityHelpers.ToEntity<ActivityLogDto, ActivityLogEntity>(this);
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)