Refactor. Add data layer
This commit is contained in:
1 parent
3b7e4e6ec5
commit
b6b794f0b4
82 files changed
+2930
-2811
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BudgetApp.Data.Entities;
|
||||
|
||||
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"
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user