Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/pabloeferreyra/Turnero/llms.txt

Use this file to discover all available pages before exploring further.

Before any appointments can be booked, an administrator must define the available time slots for the clinic’s schedule. Each time slot is stored as a TimeTurn record and appears in the dropdown that staff and patients use when creating or editing an appointment. There is no hard-coded schedule — every option the booking form offers comes directly from the TimeTurn table, so the system is fully flexible around your clinic’s operating hours.

The TimeTurn Model

public class TimeTurn
{
    public Guid                 Id    { get; set; }
    public string?              Time  { get; set; }
    public ICollection<Turn>?   Turns { get; set; }
}
FieldTypeDescription
IdGuidAuto-generated primary key
TimestringThe display value shown in the booking dropdown (e.g. "08:00")
TurnsNavigationAll appointments that reference this time slot

How Time Slots Are Used

When a user opens the appointment create or edit form, the controller calls getTimeTurns.GetCachedTimes() to retrieve the full list of TimeTurn records from memory and populates a dropdown with each record’s Time string. The selected TimeTurn.Id is stored on the appointment (Turn) as a foreign key (TimeId). This means every appointment is permanently linked to a specific TimeTurn record — deleting the record later does not remove the appointment, but it does leave that TimeId pointing to a row that no longer exists.

Caching

Time slot records are loaded from the database once at application startup and held in memory under the cache key "timeTurns". All subsequent requests for the time slot list read from this cache rather than querying the database.
// Program.cs — cache warm-up at startup
await timeTurnsRepository.GetCachedTimes();
Because the list is cached at startup, newly created time slots will not appear in the appointment booking dropdown until the application is restarted. Plan your time slot configuration before going live, or restart the app after making changes.

Creating a Time Slot

1

Open the Create form

Navigate to GET /TimeTurn/Create. A blank form is displayed with an Id (Guid) field and a Time text field.
2

Enter the time value

Type the time string into the Time field. Use 24-hour HH:mm format for consistency across the schedule (e.g. "08:00", "08:30", "14:00"). The value is stored and displayed exactly as entered — there is no automatic formatting.
3

Save the time slot

Submit the form to POST /TimeTurn/Create. The controller binds only the Id and Time fields:
public async Task<IActionResult> Create([Bind("Id,Time")] TimeTurn timeTurnViewModel)
{
    if (ModelState.IsValid)
    {
        await insertTimeTurn.Create(timeTurnViewModel);
        return RedirectToAction(nameof(Index));
    }
    return View(timeTurnViewModel);
}
On success the user is redirected to /TimeTurn/Index.
Use consistent HH:mm formatting for all time slots. Mixed formats such as "8:00", "08:00 AM", and "8 am" will all display correctly as strings but will sort unpredictably in the dropdown.

Deleting a Time Slot

1

Open the confirmation page

Navigate to GET /TimeTurn/Delete/{id}. The controller loads the record with getTimeTurns.GetTimeTurn(id) and displays it for review. A 404 Not Found response is returned if the ID does not exist.
2

Confirm the deletion

Submit the confirmation to POST /TimeTurn/Delete (action name Delete, mapped internally to DeleteConfirmed). The controller calls deleteTimeTurn.Delete(timeTurnViewModel) and redirects to the index.
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(Guid id)
{
    var timeTurnViewModel = await getTimeTurns.GetTimeTurn(id);
    deleteTimeTurn.Delete(timeTurnViewModel);
    return RedirectToAction(nameof(Index));
}
Deleting a TimeTurn record that is referenced by existing appointments will leave those appointments with an orphaned TimeId foreign key. The appointments themselves are not deleted automatically. Before removing a time slot, search for appointments using that slot and update or delete them first.

Example Time Slot Configuration

The table below shows a typical morning/afternoon schedule for a clinic with 30-minute appointments:
TimePeriod
08:00Morning
08:30Morning
09:00Morning
09:30Morning
10:00Morning
10:30Morning
11:00Morning
11:30Morning
14:00Afternoon
14:30Afternoon
15:00Afternoon
15:30Afternoon
16:00Afternoon
16:30Afternoon
17:00Afternoon
17:30Afternoon
Enter each row as a separate TimeTurn record via /TimeTurn/Create, then restart the application to warm the cache.

All Time Slot Routes at a Glance

MethodRouteDescription
GET/TimeTurn/IndexList all configured time slots
GET/TimeTurn/CreateShow the create form
POST/TimeTurn/CreateSave a new time slot (binds Id, Time)
GET/TimeTurn/Delete/{id}Show the deletion confirmation page
POST/TimeTurn/DeleteConfirm and delete the time slot
All routes under /TimeTurn/ require the Admin role. Reception staff (Ingreso) and doctors (Medico) can use time slots in the booking form but cannot create or delete them.

Build docs developers (and LLMs) love