Skip to content

Commit

Permalink
Merge pull request #9 from chenxidev1129/6-add-some-tables-for-task-m…
Browse files Browse the repository at this point in the history
…anagement

6 add some tables for task management
  • Loading branch information
gitfullstacker authored Dec 11, 2023
2 parents 7f83107 + 9dc7cb4 commit af3ac3e
Show file tree
Hide file tree
Showing 55 changed files with 2,608 additions and 36 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,7 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# Upload foler
taskmaster-api/Uploads/
51 changes: 51 additions & 0 deletions taskmaster-api/Controllers/ActivityLogController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using taskmaster_api.Data.DTOs;
using taskmaster_api.Services.Interface;

namespace taskmaster_api.Controllers
{
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class ActivityLogController : ApplicationControllerBase
{
private readonly IActivityLogService _activityLogService;

public ActivityLogController(IActivityLogService activityLogService)
{
_activityLogService = activityLogService;
}

[HttpGet]
public IActionResult GetAllActivityLogs()
{
return ToHttpResult<List<ActivityLogDto>>(_activityLogService.GetAllActivityLogs());
}

[HttpGet("{id}")]
public IActionResult GetActivityLog(int id)
{
return ToHttpResult<ActivityLogDto>(_activityLogService.GetActivityLogById(id));
}

[HttpPost]
public IActionResult CreateActivityLog(ActivityLogDto activityLogDto)
{
return ToHttpResult<ActivityLogDto>(_activityLogService.CreateActivityLog(activityLogDto));
}

[HttpPut("{id}")]
public IActionResult UpdateActivityLog(int id, ActivityLogDto activityLogDto)
{
return ToHttpResult<ActivityLogDto>(_activityLogService.UpdateActivityLog(id, activityLogDto));
}

[HttpDelete("{id}")]
public IActionResult DeleteActivityLog(int id)
{
return ToHttpResult(_activityLogService.DeleteActivityLog(id));
}
}
}
57 changes: 57 additions & 0 deletions taskmaster-api/Controllers/AttachmentController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using taskmaster_api.Data.DTOs;
using taskmaster_api.Services.Interface;

namespace taskmaster_api.Controllers
{
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class AttachmentController : ApplicationControllerBase
{
private readonly IAttachmentService _attachmentService;

public AttachmentController(IAttachmentService attachmentService)
{
_attachmentService = attachmentService;
}

[HttpGet]
public IActionResult GetAllAttachments()
{
return ToHttpResult<List<AttachmentDto>>(_attachmentService.GetAllAttachments());
}

[HttpGet("{id}")]
public IActionResult GetAttachment(int id)
{
return ToHttpResult<AttachmentDto>(_attachmentService.GetAttachmentById(id));
}

[HttpPost]
public IActionResult CreateAttachment(AttachmentDto attachmentDto)
{
return ToHttpResult<AttachmentDto>(_attachmentService.CreateAttachment(attachmentDto));
}

[HttpPut("{id}")]
public IActionResult UpdateAttachment(int id, AttachmentDto attachmentDto)
{
return ToHttpResult<AttachmentDto>(_attachmentService.UpdateAttachment(id, attachmentDto));
}

[HttpDelete("{id}")]
public IActionResult DeleteAttachment(int id)
{
return ToHttpResult(_attachmentService.DeleteAttachment(id));
}

[HttpPost("upload")]
public IActionResult Upload([FromForm] AttachmentUploadRequest request)
{
return ToHttpResult(_attachmentService.UploadFile(request));
}
}
}
51 changes: 51 additions & 0 deletions taskmaster-api/Controllers/CommentController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using taskmaster_api.Data.DTOs;
using taskmaster_api.Services;
using taskmaster_api.Services.Interface;

namespace taskmaster_api.Controllers
{
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class CommentController : ApplicationControllerBase
{
private readonly ICommentService _commentService;

public CommentController(ICommentService commentService)
{
_commentService = commentService;
}

[HttpGet]
public IActionResult GetAllComments()
{
return ToHttpResult<List<CommentDto>>(_commentService.GetAllComments());
}

[HttpGet("{id}")]
public IActionResult GetComment(int id)
{
return ToHttpResult<CommentDto>(_commentService.GetCommentById(id));
}

[HttpPost]
public IActionResult CreateComment(CommentDto commentDto)
{
return ToHttpResult<CommentDto>(_commentService.CreateComment(commentDto));
}

[HttpPut("{id}")]
public IActionResult UpdateComment(int id, CommentDto commentDto)
{
return ToHttpResult<CommentDto>(_commentService.UpdateComment(id, commentDto));
}

[HttpDelete("{id}")]
public IActionResult DeleteComment(int id)
{
return ToHttpResult(_commentService.DeleteComment(id));
}
}
}
51 changes: 51 additions & 0 deletions taskmaster-api/Controllers/NotificationController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using taskmaster_api.Data.DTOs;
using taskmaster_api.Services.Interface;

namespace taskmaster_api.Controllers
{
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class NotificationController : ApplicationControllerBase
{
private readonly INotificationService _notificationService;

public NotificationController(INotificationService notificationService)
{
_notificationService = notificationService;
}

[HttpGet]
public IActionResult GetAllNotifications()
{
return ToHttpResult<List<NotificationDto>>(_notificationService.GetAllNotifications());
}

[HttpGet("{id}")]
public IActionResult GetNotification(int id)
{
return ToHttpResult<NotificationDto>(_notificationService.GetNotificationById(id));
}

[HttpPost]
public IActionResult CreateNotification(NotificationDto notificationDto)
{
return ToHttpResult<NotificationDto>(_notificationService.CreateNotification(notificationDto));
}

[HttpPut("{id}")]
public IActionResult UpdateNotification(int id, NotificationDto notificationDto)
{
return ToHttpResult<NotificationDto>(_notificationService.UpdateNotification(id, notificationDto));
}

[HttpDelete("{id}")]
public IActionResult DeleteNotification(int id)
{
return ToHttpResult(_notificationService.DeleteNotification(id));
}
}
}
51 changes: 51 additions & 0 deletions taskmaster-api/Controllers/SettingController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using taskmaster_api.Data.DTOs;
using taskmaster_api.Services.Interface;

namespace taskmaster_api.Controllers
{
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class SettingController : ApplicationControllerBase
{
private readonly ISettingService _settingService;

public SettingController(ISettingService settingService)
{
_settingService = settingService;
}

[HttpGet]
public IActionResult GetAllSettings()
{
return ToHttpResult<List<SettingDto>>(_settingService.GetAllSettings());
}

[HttpGet("{id}")]
public IActionResult GetSetting(int id)
{
return ToHttpResult<SettingDto>(_settingService.GetSettingById(id));
}

[HttpPost]
public IActionResult CreateSetting(SettingDto settingDto)
{
return ToHttpResult<SettingDto>(_settingService.CreateSetting(settingDto));
}

[HttpPut("{id}")]
public IActionResult UpdateSetting(int id, SettingDto settingDto)
{
return ToHttpResult<SettingDto>(_settingService.UpdateSetting(id, settingDto));
}

[HttpDelete("{id}")]
public IActionResult DeleteSetting(int id)
{
return ToHttpResult(_settingService.DeleteSetting(id));
}
}
}
49 changes: 49 additions & 0 deletions taskmaster-api/Controllers/TagController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using taskmaster_api.Data.DTOs;
using taskmaster_api.Services.Interface;

namespace taskmaster_api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TagController : ApplicationControllerBase
{
private readonly ITagService _tagService;

public TagController(ITagService tagService)
{
_tagService = tagService;
}

[HttpGet]
public IActionResult GetAllTags()
{
return ToHttpResult<List<TagDto>>(_tagService.GetAllTags());
}

[HttpGet("{id}")]
public IActionResult GetTag(int id)
{
return ToHttpResult<TagDto>(_tagService.GetTagById(id));
}

[HttpPost]
public IActionResult CreateTag(TagDto tagDto)
{
return ToHttpResult<TagDto>(_tagService.CreateTag(tagDto));
}

[HttpPut("{id}")]
public IActionResult UpdateTag(int id, TagDto tagDto)
{
return ToHttpResult<TagDto>(_tagService.UpdateTag(id, tagDto));
}

[HttpDelete("{id}")]
public IActionResult DeleteTag(int id)
{
return ToHttpResult(_tagService.DeleteTag(id));
}
}
}
7 changes: 7 additions & 0 deletions taskmaster-api/Controllers/TaskController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using taskmaster_api.Data.DTOs;
using taskmaster_api.Data.Models;
using taskmaster_api.Services;
using taskmaster_api.Services.Interface;

namespace taskmaster_api.Controllers
Expand All @@ -18,6 +19,12 @@ public TaskController(ITaskService taskService)
_taskService = taskService;
}

[HttpGet]
public IActionResult GetAllTasks()
{
return ToHttpResult<List<TaskDto>>(_taskService.GetAllTasks());
}

[HttpGet("{id}")]
public IActionResult GetTask(int id)
{
Expand Down
9 changes: 8 additions & 1 deletion taskmaster-api/Data/Contexts/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using taskmaster_api.Data.Entities;

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

public virtual DbSet<TaskEntity> Tasks { get; set; }
public virtual DbSet<CommentEntity> Comments { get; set; }
public virtual DbSet<AttachmentEntity> Attachments { get; set; }
public virtual DbSet<TagEntity> Tags { get; set; }
public virtual DbSet<ActivityLogEntity> ActivityLogs { get; set; }
public virtual DbSet<NotificationEntity> Notifications { get; set; }
public virtual DbSet<SettingEntity> Settings { get; set; }
}
}
27 changes: 27 additions & 0 deletions taskmaster-api/Data/DTOs/ActivityLogDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using taskmaster_api.Data.DTOs.Interface;
using taskmaster_api.Data.Entities;
using taskmaster_api.Utilities;

namespace taskmaster_api.Data.DTOs
{
public class ActivityLogDto : IDto<ActivityLogEntity>
{
public int? Id { get; set; }
public string UserId { get; set; }
public string Action { get; set; }
public DateTime CreatedAt { get; set; }

public ActivityLogDto()
{
if (!Id.HasValue)
{
CreatedAt = DateTime.UtcNow;
}
}

public ActivityLogEntity ToEntity()
{
return EntityHelpers.ToEntity<ActivityLogDto, ActivityLogEntity>(this);
}
}
}
Loading

0 comments on commit af3ac3e

Please sign in to comment.