using System.ComponentModel.DataAnnotations; namespace BudgetApp.Data; public class Salary { public int Id { get; set; } [Required, MaxLength(200)] public string Name { get; set; } = string.Empty; public decimal Amount { get; set; } public RecurrenceType RecurrenceType { get; set; } = RecurrenceType.Monthly; public DateTime StartDate { get; set; } = DateTime.Today; public int AccountId { get; set; } public Account Account { get; set; } = default!; public int? CategoryId { get; set; } public Category? Category { get; set; } [Required] public string UserId { get; set; } = string.Empty; public ApplicationUser User { get; set; } = default!; public string GetPaydaySummary() => RecurrenceType switch { RecurrenceType.Weekly => $"Every week on {StartDate:dddd}", RecurrenceType.Monthly => $"Monthly on the {GetOrdinal(StartDate.Day)}", RecurrenceType.Yearly => $"Annually on {StartDate:MMMM d}", _ => RecurrenceType.ToString() }; private static string GetOrdinal(int day) => day switch { 1 or 21 or 31 => $"{day}st", 2 or 22 => $"{day}nd", 3 or 23 => $"{day}rd", _ => $"{day}th" }; }