Add project files.
This commit is contained in:
61
Nevyn/Models/Money.cs
Normal file
61
Nevyn/Models/Money.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
namespace Nevyn.Models
|
||||
{
|
||||
public class Wallet
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int TotalAmount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Kort + this.Buffert + this.Spara + this.Fonder;
|
||||
}
|
||||
}
|
||||
public int Kort { get; set; }
|
||||
public int Buffert { get; set; }
|
||||
public int Spara { get; set; }
|
||||
public int Fonder { get; set; }
|
||||
|
||||
public int MoneyUntilSalary {
|
||||
get
|
||||
{
|
||||
DateTime payDay = SalaryCalculator.CalculatePayDay(DateTime.Now);
|
||||
this.DaysLeftUntilSalary = (payDay - DateTime.Now).Days;
|
||||
return this.Kort / this.DaysLeftUntilSalary;
|
||||
}
|
||||
}
|
||||
public int DaysLeftUntilSalary { get; set; }
|
||||
|
||||
public class SalaryCalculator
|
||||
{
|
||||
public static DateTime CalculatePayDay(DateTime date)
|
||||
{
|
||||
// Get the 25th of the current month
|
||||
var payDay = new DateTime(date.Year, date.Month, 25);
|
||||
|
||||
// If the 25th is on a weekend, get the previous Friday
|
||||
if (payDay.DayOfWeek == DayOfWeek.Saturday)
|
||||
{
|
||||
payDay = payDay.AddDays(-1);
|
||||
}
|
||||
else if (payDay.DayOfWeek == DayOfWeek.Sunday)
|
||||
{
|
||||
payDay = payDay.AddDays(-2);
|
||||
}
|
||||
|
||||
return payDay;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class WalletDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int TotalAmount { get; set; }
|
||||
public int AmountLeftPerDay { get; set; }
|
||||
public int Kort { get; set; }
|
||||
public string Debug { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
14
Nevyn/Models/MoneyContext.cs
Normal file
14
Nevyn/Models/MoneyContext.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Nevyn.Models
|
||||
{
|
||||
public class MoneyContext : DbContext
|
||||
{
|
||||
public MoneyContext(DbContextOptions<MoneyContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DbSet<Wallet> UpdateWallet { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
14
Nevyn/Models/ShoppingContext.cs
Normal file
14
Nevyn/Models/ShoppingContext.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Nevyn.Models
|
||||
{
|
||||
public class ShoppingContext : DbContext
|
||||
{
|
||||
public ShoppingContext(DbContextOptions<ShoppingContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DbSet<ShoppingList> UpdateShopping { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
20
Nevyn/Models/ShoppingList.cs
Normal file
20
Nevyn/Models/ShoppingList.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Nevyn.Models
|
||||
{
|
||||
public class ShoppingList
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public int Amount { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool IsComplete { get; set; }
|
||||
public string? Secret { get; set; }
|
||||
|
||||
}
|
||||
public class ShoppingListDTO
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public int Amount { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool IsComplete { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user