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

Reduce code in POST/PUT operations of controllers #141

Closed
MrDave1999 opened this issue Jan 20, 2023 · 0 comments · Fixed by #143
Closed

Reduce code in POST/PUT operations of controllers #141

MrDave1999 opened this issue Jan 20, 2023 · 0 comments · Fixed by #143
Labels
refactor Refactoring existing code, to make it more readable, cleaner or more efficient

Comments

@MrDave1999
Copy link
Member

MrDave1999 commented Jan 20, 2023

SAMPLES

The following codes can be simplified by using the ternary operator:

public async Task<ActionResult<Response<DtoBase>>> Post([FromBody]AppointmentInsertDto appointmentInsertDto)
{
var response = await _appointmentService.CreateAppointmentAsync(appointmentInsertDto);
if (response.Success)
return CreatedAtAction(nameof(Post), response);
return BadRequest(response);
}

public async Task<ActionResult<Response>> Put(int id, [FromBody]AppointmentUpdateDto appointmentUpdateDto)
{
var response = await _appointmentService.UpdateAppointmentAsync(id, User, appointmentUpdateDto);
if (response.Success)
return Ok(response);
return BadRequest(response);
}

@MrDave1999 MrDave1999 converted this from a draft issue Jan 20, 2023
@MrDave1999 MrDave1999 added the refactor Refactoring existing code, to make it more readable, cleaner or more efficient label Jan 20, 2023
@MrDave1999 MrDave1999 modified the milestone: v1.0.0 Jan 20, 2023
@MrDave1999 MrDave1999 linked a pull request Jan 25, 2023 that will close this issue
@github-project-automation github-project-automation bot moved this from To Do to Done in DentallApp (first stage) Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactoring existing code, to make it more readable, cleaner or more efficient
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant