Skip to content

Commit

Permalink
fix: schedule part
Browse files Browse the repository at this point in the history
  • Loading branch information
anhdtn2403 committed Jul 22, 2024
1 parent ee9f7be commit acb0e11
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public async Task<IActionResult> Edit([Bind("ID,ManagerID,Name,Province,Ward,Dis
TimeOnly pmS = clinic.PmStartTime;
TimeOnly pmE = clinic.PmEndTime;
//--------------------------------------KIỂM TRA GIỜ HỢP LỆ KHÔNG?
if (amS >= amE || pmS >= pmE)
if (amS > amE || pmS > pmE)
{
TempData["ToastMessageFailTempData"] = "Thời gian làm việc không hợp lệ.";
return View(clinic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using Newtonsoft.Json;
using System.Collections;
using Microsoft.AspNetCore.Authorization;
using Dental_Clinic_System.Helper;
using static Dental_Clinic_System.Services.VNPAY.VNPAYLibrary;

namespace Dental_Clinic_System.Areas.Manager.Controllers
{
Expand Down Expand Up @@ -46,7 +48,7 @@ public async Task<IActionResult> GetBookedSchedule(string type, int? dentistId,
//---------------------------------------------------
//Lấy các lịch trong Appointment Table
// Filter schedules from today onwards
var today = DateOnly.FromDateTime(DateTime.Today);
var today = DateOnly.FromDateTime(Util.GetUtcPlus7Time());
var sche_Appointment = _context.Appointments.Include(a => a.Schedule).ThenInclude(s => s.Dentist).ThenInclude(d => d.Account).Include(a => a.Schedule).ThenInclude(s => s.TimeSlot).Where(a => a.Schedule.Dentist.ClinicID == clinicId && a.Schedule.Date >= today);
var sche_FutureAppts = _context.PeriodicAppointments.Include(f => f.Dentist).Where(f => f.Dentist.ClinicID == clinicId && f.DesiredDate >= today);
//--------------------------------------------------
Expand Down Expand Up @@ -140,7 +142,7 @@ public async Task<IActionResult> Index(int? dentistId, DateTime? date, string st

//--------------------------------------------------
// Filter schedules from today onwards
var today = DateOnly.FromDateTime(DateTime.Today);
var today = DateOnly.FromDateTime(Util.GetUtcPlus7Time());
var schedulesQuery = _context.Schedules
.Include(s => s.Dentist)
.ThenInclude(d => d.Account)
Expand Down Expand Up @@ -197,7 +199,7 @@ public async Task<IActionResult> ViewHistory(string type, int? dentistId, DateTi
//---------------------------------------------------
//Lấy các lịch trong Appointment Table
// Filter schedules from today view history
var today = DateOnly.FromDateTime(DateTime.Today);
var today = DateOnly.FromDateTime(Util.GetUtcPlus7Time());
var sche_Appointment = _context.Appointments.Include(a => a.Schedule).ThenInclude(s => s.Dentist).ThenInclude(d => d.Account).Include(a => a.Schedule).ThenInclude(s => s.TimeSlot).Where(a => a.Schedule.Dentist.ClinicID == clinicId && a.Schedule.Date < today);
var sche_FutureAppts = _context.PeriodicAppointments.Include(f => f.Dentist).Where(f => f.Dentist.ClinicID == clinicId && f.DesiredDate < today);
//--------------------------------------------------
Expand Down Expand Up @@ -259,7 +261,7 @@ public async Task<IActionResult> ViewHistory(string type, int? dentistId, DateTi
});
}
}
return View("ViewHistory", bookedSchedules.OrderBy(b => b.Date).ToList());
return View("ViewHistory", bookedSchedules.OrderByDescending(b => b.Date).ToList());
}
private List<int> GenerateTimeSlotIDs(TimeOnly startTime, TimeOnly endTime)
{
Expand Down Expand Up @@ -421,7 +423,7 @@ public async Task<IActionResult> CreateWeekSchedule(string selectedDates)
await _context.SaveChangesAsync();
}

var today = DateOnly.FromDateTime(DateTime.Today);
var today = DateOnly.FromDateTime(Util.GetUtcPlus7Time());
if (today < dates[0])
{
TempData["ToastMessageSuccessTempData"] = "Thành công tạo lịch khám từ ngày " + dates[0].ToString("dd/MM/yyyy") + " đến " + dates[6].ToString("dd/MM/yyyy");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
<th>Mô tả</th>
</tr>
</thead>
<tbody id="myTableBody">
<tbody @* id="myTableBody" *@>
@{
int index = 0; //đếm STT của table
}
Expand Down Expand Up @@ -278,8 +278,8 @@
</div>

<!-- ========== PAGINATION ========== -->
<ul id="pagination" class="pagination">
</ul>
@* <ul id="pagination" class="pagination">
</ul> *@

@section Scripts {
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
<th>Hành động</th>
</tr>
</thead>
<tbody id="myTableBody">
<tbody @* id="myTableBody" *@>
@{
var groupedData = Model.GroupBy(s => new { s.Date, s.DentistID });
int index = 0; //đếm STT của table
Expand Down Expand Up @@ -420,8 +420,8 @@
</div>

<!-- ========== PAGINATION ========== -->
<ul id="pagination" class="pagination">
</ul>
@* <ul id="pagination" class="pagination">
</ul> *@
<!-- Modal xác nhận -->
<div class="modal fade" id="confirmModal" tabindex="-1" aria-labelledby="confirmModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
Expand Down

0 comments on commit acb0e11

Please sign in to comment.