Skip to content
Merged
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
12 changes: 12 additions & 0 deletions Src/Core/F10/BusinessLogic/F10Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ public async Task<F10AppResponseModel> ExecuteAsync(
CancellationToken ct
)
{
if (request.TodoTaskListId != 0)
{
var doesListExtst = await _repository.Value.DoesTodoTaskListExistAsync(
request.TodoTaskListId,
ct
);
if (!doesListExtst)
{
return F10Constant.DefaultResponse.App.TODO_TASK_LIST_NOT_FOUND;
}
}

var foundTodoTaskLists = await _repository.Value.GetTodoTaskListAsync(
request.TodoTaskListId,
request.NumberOfRecord,
Expand Down
17 changes: 16 additions & 1 deletion Src/Core/F10/Common/F10Constant.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using F10.Models;
using F10.Presentation;
using Microsoft.AspNetCore.Http;

Expand All @@ -19,7 +20,13 @@ public static class Query

public static class DefaultResponse
{
public static class App { }
public static class App
{
public static readonly F10AppResponseModel TODO_TASK_LIST_NOT_FOUND = new()
{
AppCode = AppCode.TODO_TASK_LIST_NOT_FOUND,
};
}

public static class Http
{
Expand All @@ -28,6 +35,12 @@ public static class Http
AppCode = (int)AppCode.VALIDATION_FAILED,
HttpCode = StatusCodes.Status400BadRequest,
};

public static readonly F10Response TODO_TASK_LIST_NOT_FOUND = new()
{
AppCode = (int)AppCode.TODO_TASK_LIST_NOT_FOUND,
HttpCode = StatusCodes.Status404NotFound,
};
}
}

Expand All @@ -36,5 +49,7 @@ public enum AppCode
SUCCESS = 1,

VALIDATION_FAILED,

TODO_TASK_LIST_NOT_FOUND,
}
}
5 changes: 5 additions & 0 deletions Src/Core/F10/DataAccess/F10Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public F10Repository(AppDbContext context)
_appContext = context;
}

public Task<bool> DoesTodoTaskListExistAsync(long listId, CancellationToken ct)
{
return _appContext.Set<TodoTaskListEntity>().AnyAsync(entity => entity.Id == listId, ct);
}

public async Task<IEnumerable<F10TodoTaskListModel>> GetTodoTaskListAsync(
long todoTaskListId,
int numberOfRecord,
Expand Down
2 changes: 2 additions & 0 deletions Src/Core/F10/DataAccess/IF10Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ Task<IEnumerable<F10TodoTaskListModel>> GetTodoTaskListAsync(
int numberOfRecord,
CancellationToken ct
);

Task<bool> DoesTodoTaskListExistAsync(long listId, CancellationToken ct);
}
5 changes: 5 additions & 0 deletions Src/Core/F10/Mapper/F10HttpResponseMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ private static void Init()
},
}
);

_httpResponseMapper.TryAdd(
F10Constant.AppCode.TODO_TASK_LIST_NOT_FOUND,
(appRequest, appResponse) => F10Constant.DefaultResponse.Http.TODO_TASK_LIST_NOT_FOUND
);
}

public static F10Response Get(F10AppRequestModel appRequest, F10AppResponseModel appResponse)
Expand Down
4 changes: 0 additions & 4 deletions Src/Core/F13/Common/F13Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ public static class App
public static readonly F13AppResponseModel TASK_NOT_FOUND = new()
{
AppCode = AppCode.TASK_NOT_FOUND,
Body = new() { TodoTasks = [], NextCursor = 0 },
};

public static readonly F13AppResponseModel TODO_TASK_LIST_NOT_FOUND = new()
{
AppCode = AppCode.TODO_TASK_LIST_NOT_FOUND,
Body = new() { TodoTasks = [], NextCursor = 0 },
};
}

Expand All @@ -48,14 +46,12 @@ public static class Http
{
AppCode = (int)AppCode.TASK_NOT_FOUND,
HttpCode = StatusCodes.Status404NotFound,
Body = new() { TodoTasks = [], NextCursor = 0 },
};

public static readonly F13Response TODO_TASK_LIST_NOT_FOUND = new()
{
AppCode = (int)AppCode.TODO_TASK_LIST_NOT_FOUND,
HttpCode = StatusCodes.Status404NotFound,
Body = new() { TodoTasks = [], NextCursor = 0 },
};
}
}
Expand Down
4 changes: 0 additions & 4 deletions Src/Core/F14/Common/F14Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ public static class App
public static readonly F14AppResponseModel TASK_NOT_FOUND = new()
{
AppCode = AppCode.TASK_NOT_FOUND,
Body = new() { TodoTasks = [], NextCursor = 0 },
};

public static readonly F14AppResponseModel TODO_TASK_LIST_NOT_FOUND = new()
{
AppCode = AppCode.TODO_TASK_LIST_NOT_FOUND,
Body = new() { TodoTasks = [], NextCursor = 0 },
};
}

Expand All @@ -48,14 +46,12 @@ public static class Http
{
AppCode = (int)AppCode.TASK_NOT_FOUND,
HttpCode = StatusCodes.Status404NotFound,
Body = new() { TodoTasks = [], NextCursor = 0 },
};

public static readonly F14Response TODO_TASK_LIST_NOT_FOUND = new()
{
AppCode = (int)AppCode.TODO_TASK_LIST_NOT_FOUND,
HttpCode = StatusCodes.Status404NotFound,
Body = new() { TodoTasks = [], NextCursor = 0 },
};
}
}
Expand Down
Loading