Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription notifications #175

Merged
merged 4 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions subtrack.DAL/Entities/DateTimeSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class DateTimeSetting : SettingsBase
{
public const string LastAutoPaymentTimeStampKey = "LastAutoPaymentTimeStamp";
public const string LastSubscriptionExportTimeStampKey = "LastSubscriptionExportTimeStamp";
public const string LastSubscriptionReminderTimeStampKey = "LastSubscriptionReminderTimeStampKey";
public DateTime? Value { get; set; }
}
}
7 changes: 5 additions & 2 deletions subtrack.DAL/Entities/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
public int Id { get; set; }

[Required]
[StringLength(50,ErrorMessage = "Service name should be less than 50 characters.")]
[StringLength(50, ErrorMessage = "Service name should be less than 50 characters.")]
public string Name { get; set; } = null!;
public string? Description { get; set; }
public bool IsAutoPaid { get; set; }

public decimal Cost { get; set; }

[Required]
public int FirstPaymentDay { get; set; }
public int FirstPaymentDay { get; set; }
[Required]
public DateTime LastPayment { get; set; }

Expand All @@ -26,12 +26,15 @@
[Range(1, int.MaxValue, ErrorMessage = "Interval has to be greater than 0")]
public int BillingInterval { get; set; }

public string PrimaryColor { get; set; }

Check warning on line 29 in subtrack.DAL/Entities/Subscription.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'PrimaryColor' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public string? Icon { get; set; }

public string SecondaryColor { get; set; }

Check warning on line 33 in subtrack.DAL/Entities/Subscription.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'SecondaryColor' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Range(0, 31, ErrorMessage = "Notification can be set up to 31 days before due date")]
public int? NotificationDays { get; set; }

public object Clone()
{
return (Subscription)MemberwiseClone();
Expand Down
118 changes: 118 additions & 0 deletions subtrack.DAL/Migrations/20240509182319_NotificationDays.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions subtrack.DAL/Migrations/20240509182319_NotificationDays.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace subtrack.DAL.Migrations
{
/// <inheritdoc />
public partial class NotificationDays : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "NotificationDays",
table: "Subscriptions",
type: "INTEGER",
nullable: true);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "NotificationDays",
table: "Subscriptions");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions subtrack.DAL/Migrations/20240510155420_LastReminderTimestamp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace subtrack.DAL.Migrations
{
/// <inheritdoc />
public partial class LastReminderTimestamp : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "Settings",
columns: new[] { "Id", "Value", "settings_type" },
values: new object[] { "LastSubscriptionReminderTimeStampKey", null, "DateTimeSetting" });
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Settings",
keyColumn: "Id",
keyValue: "LastSubscriptionReminderTimeStampKey");
}
}
}
7 changes: 7 additions & 0 deletions subtrack.DAL/Migrations/SubtrackDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(50)
.HasColumnType("TEXT");

b.Property<int?>("NotificationDays")
.HasColumnType("INTEGER");

b.Property<string>("PrimaryColor")
.IsRequired()
.HasColumnType("TEXT")
Expand Down Expand Up @@ -104,6 +107,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
new
{
Id = "LastSubscriptionExportTimeStamp"
},
new
{
Id = "LastSubscriptionReminderTimeStampKey"
});
});
#pragma warning restore 612, 618
Expand Down
1 change: 1 addition & 0 deletions subtrack.DAL/SubtrackDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<DateTimeSetting>().HasData(new DateTimeSetting { Id = DateTimeSetting.LastAutoPaymentTimeStampKey, Value = null });
modelBuilder.Entity<DateTimeSetting>().HasData(new DateTimeSetting { Id = DateTimeSetting.LastSubscriptionExportTimeStampKey, Value = null });
modelBuilder.Entity<DateTimeSetting>().HasData(new DateTimeSetting { Id = DateTimeSetting.LastSubscriptionReminderTimeStampKey, Value = null });

modelBuilder.Entity<Subscription>(entity =>
{
Expand Down
6 changes: 3 additions & 3 deletions subtrack.MAUI/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ private static void SeedDb(SubtrackDbContext dbContext)
var todayLastMonth = DateTime.Now.AddMonths(-1);
var availableBackgroundColors = CssUtil.AvailableBackgroundColors;
dbContext.Subscriptions.AddRange(
new DAL.Entities.Subscription() { Name = "paramount", LastPayment = todayLastMonth.AddDays(-1), FirstPaymentDay = todayLastMonth.AddDays(-1).Day, Cost = 3m, BillingOccurrence = DAL.Entities.BillingOccurrence.Week, BillingInterval = 2, PrimaryColor = availableBackgroundColors.First(), SecondaryColor = "#2a9fd6", Icon = "fa fa-tv" },
new DAL.Entities.Subscription() { Name = "Disney+", LastPayment = todayLastMonth, FirstPaymentDay = todayLastMonth.Day, Cost = 3m, BillingOccurrence = DAL.Entities.BillingOccurrence.Month, BillingInterval = 1, PrimaryColor = availableBackgroundColors.First(), SecondaryColor = "#2a9fd6", Icon = "fa fa-circle-play" },
new DAL.Entities.Subscription() { Name = "Netflix Premium Plan", LastPayment = DateTime.Now.AddDays(-1), FirstPaymentDay = DateTime.Now.AddDays(-1).Day, IsAutoPaid = true, Description = "family plan", Cost = 1000, BillingOccurrence = DAL.Entities.BillingOccurrence.Month, BillingInterval = 1, PrimaryColor = availableBackgroundColors.First(), SecondaryColor = "#2a9fd6" },
new DAL.Entities.Subscription() { Name = "paramount", LastPayment = todayLastMonth.AddDays(-1), FirstPaymentDay = todayLastMonth.AddDays(-1).Day, Cost = 3m, BillingOccurrence = DAL.Entities.BillingOccurrence.Week, BillingInterval = 2, PrimaryColor = availableBackgroundColors.First(), SecondaryColor = "#2a9fd6", Icon = "fa fa-tv", NotificationDays = 0 },
new DAL.Entities.Subscription() { Name = "Disney+", LastPayment = todayLastMonth, FirstPaymentDay = todayLastMonth.Day, Cost = 3m, BillingOccurrence = DAL.Entities.BillingOccurrence.Month, BillingInterval = 1, PrimaryColor = availableBackgroundColors.First(), SecondaryColor = "#2a9fd6", Icon = "fa fa-circle-play", NotificationDays = 0 },
new DAL.Entities.Subscription() { Name = "Netflix Premium Plan", LastPayment = DateTime.Now.AddDays(-1), FirstPaymentDay = DateTime.Now.AddDays(-1).Day, IsAutoPaid = true, Description = "family plan", Cost = 1000, BillingOccurrence = DAL.Entities.BillingOccurrence.Month, BillingInterval = 1, PrimaryColor = availableBackgroundColors.First(), SecondaryColor = "#2a9fd6", NotificationDays = 1 },
new DAL.Entities.Subscription() { Name = "Something Family Plan", LastPayment = DateTime.Now.AddDays(-150), FirstPaymentDay = DateTime.Now.AddDays(-150).Day, IsAutoPaid = false, Description = "family plan", Cost = 1000, BillingOccurrence = DAL.Entities.BillingOccurrence.Week, BillingInterval = 2, PrimaryColor = availableBackgroundColors.First(), SecondaryColor = "#2a9fd6", Icon = "fa fa-shield" },
new DAL.Entities.Subscription() { Name = "hbo", LastPayment = DateTime.Now, FirstPaymentDay = DateTime.Now.Day, Cost = 1.5m, BillingOccurrence = DAL.Entities.BillingOccurrence.Year, BillingInterval = 1, PrimaryColor = availableBackgroundColors.First(), SecondaryColor = "#2a9fd6" },
new DAL.Entities.Subscription() { Name = "hulu Standard plan", LastPayment = DateTime.Now.AddMonths(-2), FirstPaymentDay = 1, Cost = 1.5m, IsAutoPaid = true, BillingOccurrence = DAL.Entities.BillingOccurrence.Month, BillingInterval = 3, PrimaryColor = availableBackgroundColors.First(), SecondaryColor = "#2a9fd6", Icon = "fa fa-circle-play" }
Expand Down
Loading
Loading