Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created October 22, 2025 15:19
Show Gist options
  • Select an option

  • Save dcomartin/2e3349bb3b9102bea44bf58b1d1259c0 to your computer and use it in GitHub Desktop.

Select an option

Save dcomartin/2e3349bb3b9102bea44bf58b1d1259c0 to your computer and use it in GitHub Desktop.
public enum VacationRequestStatus
{
Pending,
Approved,
Rejected
}
public class Employee
{
public Guid Id { get; private set; }
public bool IsManager { get; private set; }
public Employee(Guid id, bool isManager)
{
Id = id;
IsManager = isManager;
}
}
public class VacationRequest
{
public Guid EmployeeId { get; private set; }
public VacationRequestStatus Status { get; private set; }
public VacationRequest(Guid employeeId)
{
EmployeeId = employeeId;
Status = VacationRequestStatus.Pending;
}
public void Approve(Employee approver)
{
if (approver.IsManager == false)
{
throw new UnauthorizedAccessException("Only managers can approve vacation requests.");
}
if (Status != VacationRequestStatus.Pending)
{
throw new InvalidOperationException("Only pending requests can be approved.");
}
Status = VacationRequestStatus.Approved;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment