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

Add pagination and fix search to doctor review #97

Merged
merged 2 commits into from
Jun 29, 2024
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
2 changes: 1 addition & 1 deletion CheckDrive.Web/CheckDrive.Web/CheckDrive.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Compile Include="Controllers\OperatorReviewsController.cs" />
<Compile Include="Controllers\OperatorsController.cs" />
<Compile Include="Controllers\TechniciansController.cs" />
<PackageReference Include="CheckDrive.ApiContracts" Version="1.3.4" />
<PackageReference Include="CheckDrive.ApiContracts" Version="1.3.5" />
<PackageReference Include="CheckDrive.DTOs" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public async Task<IActionResult> Create([Bind("Login,Password,PhoneNumber,FirstN
await _accountDataStore.CreateAccountAsync(account);
return RedirectToAction(nameof(Index));
}
var roles = await GETRoles();
ViewBag.Roles = new SelectList(roles, "Id", "Name");
return View(account);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ public async Task<IActionResult> Index(int? pageNumber, string? searchString, Da
public async Task<IActionResult> PersonalIndex(int? pageNumber, string? searchString)
{
var reviewsResponse = await _doctorReviewDataStore.GetDoctorReviewsAsync(pageNumber, searchString, null, 3);


ViewBag.PageSize = reviewsResponse.PageSize;
ViewBag.PageCount = reviewsResponse.TotalPages;
ViewBag.TotalCount = reviewsResponse.TotalCount;
ViewBag.CurrentPage = reviewsResponse.PageNumber;
ViewBag.HasPreviousPage = reviewsResponse.HasPreviousPage;
ViewBag.HasNextPage = reviewsResponse.HasNextPage;

return View(reviewsResponse.Data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ private async Task<List<SelectListItem>> GETDrivers()

public async Task<IActionResult> GetCarByDriverId(int driverId)
{
var operatorReviews = await _operatorReviewDataStore.GetOperatorReviews(null, null, null);
var operatorReviews = await _operatorReviewDataStore.GetOperatorReviews(null,null, null, null);
var operatorr = operatorReviews.Data.FirstOrDefault(m => m.DriverId == driverId && m.Date.Value.Date == DateTime.Today);

if (operatorr != null)
Expand Down
2 changes: 1 addition & 1 deletion CheckDrive.Web/CheckDrive.Web/Views/Cars/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</div>
<div class="form-group">
<label asp-for="ManufacturedYear" class="control-label">Ishlab chiqarilgan yili</label>
<input asp-for="ManufacturedYear" type="date" class="form-control" />
<input asp-for="ManufacturedYear" class="form-control" />
<span asp-validation-for="ManufacturedYear" class="text-danger"></span>
</div>
<div class="form-group mt-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>
</div>

<form asp-controller="PersonalDoctorReviews" asp-action="Index">
<form asp-controller="DoctorReviews" asp-action="PersonalIndex">
<div class="container mt-5">
<div class="row justify-content-between align-items-center mb-4">
<!-- Search -->
Expand Down Expand Up @@ -88,6 +88,41 @@
}
</tbody>
</table>

<div class="d-flex justify-content-between align-items-center my-2">
<nav aria-label="Page navigation">
<ul class="pagination">
@if (ViewBag.HasPreviousPage)
{
<li class="page-item">
<a class="page-link" href="@Url.Action("PersonalIndex", new { pageNumber = 1 })" aria-label="First">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li class="page-item">
<a class="page-link" href="@Url.Action("PersonalIndex", new { pageNumber = ViewBag.CurrentPage - 1 })">@(@ViewBag.CurrentPage - 1)</a>
</li>
}
@if (ViewBag.HasNextPage)
{
<li class="page-item active">
<span class="page-link">@ViewBag.CurrentPage</span>
</li>
<li class="page-item">
<a class="page-link" href="@Url.Action("PersonalIndex", new { pageNumber = ViewBag.CurrentPage + 1 })">@(@ViewBag.CurrentPage + 1)</a>
</li>
<li class="page-item">
<a class="page-link" href="@Url.Action("PersonalIndex", new { pageNumber = ViewBag.PageCount })" aria-label="Last">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
}
</ul>
</nav>
<div class="p-2">
<p class="h6 mb-0">@ViewBag.PageCount sahifadan @ViewBag.CurrentPage tasi ( umumiy ishchilar soni: @ViewBag.TotalCount)</p>
</div>
</div>
</div>
</div>
</div>
Expand Down