134 lines
3.3 KiB
C#
134 lines
3.3 KiB
C#
#nullable enable
|
|
using System;
|
|
using System.Collections.ObjectModel;
|
|
using ReminderOrganizer.Core;
|
|
|
|
namespace ReminderOrganizer.Models
|
|
{
|
|
public class ReminderTask : ViewModelBase
|
|
{
|
|
private string _id = Guid.NewGuid().ToString();
|
|
private string _name = "New Task";
|
|
private string _description = "";
|
|
private DateTime _reminderDate = DateTime.Now.AddHours(1);
|
|
private bool _isNotified = false;
|
|
private bool _isRecurring = false;
|
|
private RecurrenceType _recurrenceType = RecurrenceType.Yearly;
|
|
|
|
public string Id
|
|
{
|
|
get => _id;
|
|
set => SetProperty(ref _id, value);
|
|
}
|
|
|
|
public string Name
|
|
{
|
|
get => _name;
|
|
set => SetProperty(ref _name, value);
|
|
}
|
|
|
|
public string Description
|
|
{
|
|
get => _description;
|
|
set => SetProperty(ref _description, value);
|
|
}
|
|
|
|
public DateTime ReminderDate
|
|
{
|
|
get => _reminderDate;
|
|
set => SetProperty(ref _reminderDate, value);
|
|
}
|
|
|
|
public bool IsNotified
|
|
{
|
|
get => _isNotified;
|
|
set => SetProperty(ref _isNotified, value);
|
|
}
|
|
|
|
public bool IsRecurring
|
|
{
|
|
get => _isRecurring;
|
|
set => SetProperty(ref _isRecurring, value);
|
|
}
|
|
|
|
public RecurrenceType RecurrenceType
|
|
{
|
|
get => _recurrenceType;
|
|
set => SetProperty(ref _recurrenceType, value);
|
|
}
|
|
|
|
public DateTime GetNextOccurrence()
|
|
{
|
|
var next = ReminderDate;
|
|
while (next <= DateTime.Now)
|
|
{
|
|
next = RecurrenceType switch
|
|
{
|
|
RecurrenceType.Daily => next.AddDays(1),
|
|
RecurrenceType.Weekly => next.AddDays(7),
|
|
RecurrenceType.Monthly => next.AddMonths(1),
|
|
RecurrenceType.Yearly => next.AddYears(1),
|
|
_ => next.AddYears(1)
|
|
};
|
|
}
|
|
return next;
|
|
}
|
|
|
|
public ReminderTask() { }
|
|
|
|
public ReminderTask(string name, string description, DateTime reminderDate)
|
|
{
|
|
Name = name;
|
|
Description = description;
|
|
ReminderDate = reminderDate;
|
|
}
|
|
}
|
|
|
|
public enum RecurrenceType
|
|
{
|
|
Daily,
|
|
Weekly,
|
|
Monthly,
|
|
Yearly
|
|
}
|
|
|
|
public class Folder : ViewModelBase
|
|
{
|
|
private string _id = Guid.NewGuid().ToString();
|
|
private string _name = "New Folder";
|
|
private ObservableCollection<ReminderTask> _tasks = new();
|
|
|
|
public string Id
|
|
{
|
|
get => _id;
|
|
set => SetProperty(ref _id, value);
|
|
}
|
|
|
|
public string Name
|
|
{
|
|
get => _name;
|
|
set => SetProperty(ref _name, value);
|
|
}
|
|
|
|
public ObservableCollection<ReminderTask> Tasks
|
|
{
|
|
get => _tasks;
|
|
set => SetProperty(ref _tasks, value);
|
|
}
|
|
|
|
public Folder() { }
|
|
|
|
public Folder(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
}
|
|
|
|
public class AppData
|
|
{
|
|
public ObservableCollection<Folder> Folders { get; set; } = new();
|
|
public string Language { get; set; } = "en";
|
|
public bool IsDarkMode { get; set; } = true;
|
|
}
|
|
}
|