-
Notifications
You must be signed in to change notification settings - Fork 6
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
Ivanchuk/Child refactor #165
Changes from 2 commits
52d2ef5
016aa6a
3bf3d59
9f8e5c5
691155f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ public ChildController(IChildService service, IStringLocalizer<SharedResource> l | |
/// Get all children from the database. | ||
/// </summary> | ||
/// <returns>List of all children.</returns> | ||
[Authorize(Roles = "admin")] | ||
[ProducesResponseType(StatusCodes.Status200OK)] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||
|
@@ -67,6 +68,29 @@ public async Task<IActionResult> GetById(long id) | |
return Ok(await service.GetById(id).ConfigureAwait(false)); | ||
} | ||
|
||
/// <summary> | ||
/// Get all children from the database by parent id. | ||
/// </summary> | ||
/// <param name="id">Id of Parent.</param> | ||
/// <returns>List of all children.</returns> | ||
[ProducesResponseType(StatusCodes.Status200OK)] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||
[HttpGet("{id}")] | ||
public async Task<IActionResult> GetByParentId(long id) | ||
{ | ||
this.ValidateId(id, localizer); | ||
|
||
var children = await service.GetAllByParent(id).ConfigureAwait(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to implement checkout whether ParentId belongs to User, who called method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dear @OlhaHoliak, |
||
|
||
if (!children.Any()) | ||
{ | ||
return NoContent(); | ||
} | ||
|
||
return Ok(children); | ||
} | ||
|
||
/// <summary> | ||
/// Method for creating a new child. | ||
/// </summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to use constants for 200 and 204 status code))
cold use this Assert.IsNotNull(result); for isnot null check))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @yfedo,
Thank you a lot for your advice. I have implemented them in the current PR.