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

include label in get all task end point #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PeterOu8
Copy link
Collaborator

@PeterOu8 PeterOu8 commented Nov 8, 2024

Modify get all task endpoint to include label

Copy link

vercel bot commented Nov 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
blotz-task-app ⬜️ Ignored (Inspect) Nov 8, 2024 10:27am

@@ -1,4 +1,6 @@
namespace BlotzTask.Models
using BlotzTask.Data.Entities;
Copy link
Owner

@Ben0189 Ben0189 Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not Using entities in models

The idea is to encap all entity related only at data layer. (loose couple to improve the maintainability, in future if the app grow larger, our database related things only have dependent at data layer and does not blend across whole application)

@@ -9,5 +11,6 @@ public class TaskItemDTO
public bool IsDone { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public Label Label { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of using label entity, i will create a new DTO class for label

Suggested change
public Label Label { get; set; }
public Label Label { get; set; }
public LabelDTO Label { get; set; }

.Select(x => new TaskItemDTO
{
Id = x.Id,
Title = x.Title
Title = x.Title,
Label = x.Label
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

over here you will need to map to new dto once you create dto class

Benefit, now you only return necessary data you need to the endpoint, e.g. you dont need label id you just dont need to have it in dto (encapsulation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants