using SQLite;
using System.Text.Json.Serialization;

namespace Blahblah.FlowerApp.Data.Model;

[Table("flowers")]
public class FlowerItem
{
    [Column("fid"), PrimaryKey, NotNull]
    public int Id { get; set; }

    [Column("uid"), NotNull]
    public int OwnerId { get; set; }

    [Column("category"), NotNull]
    public int CategoryId { get; set; }

    [Column("Name"), NotNull]
    public string Name { get; set; } = null!;

    [Column("datebuy"), JsonPropertyName("dateBuy"), NotNull]
    public long DateBuyUnixTime { get; set; }

    [Column("cost")]
    public decimal? Cost { get; set; }

    [Column("purchase")]
    public string? Purchase { get; set; }

    [Column("memo")]
    public string? Memo { get; set; }

    [Column("latitude")]
    public double? Latitude { get; set; }

    [Column("longitude")]
    public double? Longitude { get; set; }

    [Ignore]
    public PhotoItem[]? Photos { get; set; }

    [Ignore]
    public int? Distance { get; set; }

    public override string ToString()
    {
        // TODO:
        return $"id: {Id}, owner: {OwnerId}, category: {CategoryId}, name: {Name}, date: {DateBuyUnixTime}, ...";
    }
}
