using System.Text.Json.Serialization;
using salesbook.Shared.Core.Entity;
using salesbook.Shared.Core.Helpers.Enum;

namespace salesbook.Shared.Core.Dto.Activity;

public class ActivityDTO : StbActivity
{
    public JtbComt? Commessa { get; set; }
    public string? Cliente { get; set; }
    public ActivityCategoryEnum Category { get; set; }
    public bool Complete { get; set; }
    
    //Notification
    public int MinuteBefore { get; set; } = -1;
    [JsonPropertyName("notificationDate")]
    public DateTime? NotificationDate { get; set; }

    public bool Deleted { get; set; }
    
    public PositionDTO? Position { get; set; }

    public ActivityDTO Clone()
    {
        return (ActivityDTO)MemberwiseClone();
    }

    private bool Equals(ActivityDTO other)
    {
        return Commessa == other.Commessa &&
               Cliente == other.Cliente &&
               Position == other.Position &&
               MinuteBefore == other.MinuteBefore &&
               NotificationDate == other.NotificationDate &&
               Category == other.Category &&
               Complete == other.Complete && ActivityId == other.ActivityId && ActivityResultId == other.ActivityResultId && ActivityTypeId == other.ActivityTypeId && DataInsAct.Equals(other.DataInsAct) && ActivityDescription == other.ActivityDescription && ParentActivityId == other.ParentActivityId && TipoAnag == other.TipoAnag && CodAnag == other.CodAnag && CodJcom == other.CodJcom && CodJfas == other.CodJfas && Nullable.Equals(EstimatedDate, other.EstimatedDate) && Nullable.Equals(EstimatedTime, other.EstimatedTime) && Nullable.Equals(AlarmDate, other.AlarmDate) && Nullable.Equals(AlarmTime, other.AlarmTime) && Nullable.Equals(EffectiveDate, other.EffectiveDate) && Nullable.Equals(EffectiveTime, other.EffectiveTime) && ResultDescription == other.ResultDescription && Nullable.Equals(EstimatedEnddate, other.EstimatedEnddate) && Nullable.Equals(EstimatedEndtime, other.EstimatedEndtime) && Nullable.Equals(EffectiveEnddate, other.EffectiveEnddate) && Nullable.Equals(EffectiveEndtime, other.EffectiveEndtime) && UserCreator == other.UserCreator && UserName == other.UserName && Nullable.Equals(PercComp, other.PercComp) && Nullable.Equals(EstimatedHours, other.EstimatedHours) && CodMart == other.CodMart && PartitaMag == other.PartitaMag && Matricola == other.Matricola && Priorita == other.Priorita && Nullable.Equals(ActivityPlayCounter, other.ActivityPlayCounter) && ActivityEvent == other.ActivityEvent && Guarantee == other.Guarantee && Note == other.Note && Rfid == other.Rfid && IdLotto == other.IdLotto && PersonaRif == other.PersonaRif && HrNum == other.HrNum && Gestione == other.Gestione && Nullable.Equals(DataOrd, other.DataOrd) && NumOrd == other.NumOrd && IdStep == other.IdStep && IdRiga == other.IdRiga && Nullable.Equals(OraInsAct, other.OraInsAct) && IndiceGradimento == other.IndiceGradimento && NoteGradimento == other.NoteGradimento && FlagRisolto == other.FlagRisolto && FlagTipologia == other.FlagTipologia && OreRapportino == other.OreRapportino && UserModifier == other.UserModifier && Nullable.Equals(OraModAct, other.OraModAct) && Nullable.Equals(OraViewAct, other.OraViewAct) && CodVdes == other.CodVdes && CodCmac == other.CodCmac && WrikeId == other.WrikeId && CodMgrp == other.CodMgrp && PlanId == other.PlanId;
    }

    public override bool Equals(object? obj)
    {
        if (obj is null) return false;
        if (ReferenceEquals(this, obj)) return true;
        return obj.GetType() == GetType() && Equals((ActivityDTO)obj);
    }

    public override int GetHashCode()
    {
        var hashCode = new HashCode();
        hashCode.Add(ActivityId);
        hashCode.Add(ActivityResultId);
        hashCode.Add(ActivityTypeId);
        hashCode.Add(DataInsAct);
        hashCode.Add(ActivityDescription);
        hashCode.Add(ParentActivityId);
        hashCode.Add(TipoAnag);
        hashCode.Add(CodAnag);
        hashCode.Add(CodJcom);
        hashCode.Add(CodJfas);
        hashCode.Add(EstimatedDate);
        hashCode.Add(EstimatedTime);
        hashCode.Add(AlarmDate);
        hashCode.Add(AlarmTime);
        hashCode.Add(EffectiveDate);
        hashCode.Add(EffectiveTime);
        hashCode.Add(ResultDescription);
        hashCode.Add(EstimatedEnddate);
        hashCode.Add(EstimatedEndtime);
        hashCode.Add(EffectiveEnddate);
        hashCode.Add(EffectiveEndtime);
        hashCode.Add(UserCreator);
        hashCode.Add(UserName);
        hashCode.Add(PercComp);
        hashCode.Add(EstimatedHours);
        hashCode.Add(CodMart);
        hashCode.Add(PartitaMag);
        hashCode.Add(Matricola);
        hashCode.Add(Priorita);
        hashCode.Add(ActivityPlayCounter);
        hashCode.Add(ActivityEvent);
        hashCode.Add(Guarantee);
        hashCode.Add(Note);
        hashCode.Add(Rfid);
        hashCode.Add(IdLotto);
        hashCode.Add(PersonaRif);
        hashCode.Add(HrNum);
        hashCode.Add(Gestione);
        hashCode.Add(DataOrd);
        hashCode.Add(NumOrd);
        hashCode.Add(IdStep);
        hashCode.Add(IdRiga);
        hashCode.Add(OraInsAct);
        hashCode.Add(IndiceGradimento);
        hashCode.Add(NoteGradimento);
        hashCode.Add(FlagRisolto);
        hashCode.Add(FlagTipologia);
        hashCode.Add(OreRapportino);
        hashCode.Add(UserModifier);
        hashCode.Add(OraModAct);
        hashCode.Add(OraViewAct);
        hashCode.Add(CodVdes);
        hashCode.Add(CodCmac);
        hashCode.Add(WrikeId);
        hashCode.Add(CodMgrp);
        hashCode.Add(PlanId);
        hashCode.Add(Commessa);
        hashCode.Add(Cliente);
        hashCode.Add(Category);
        hashCode.Add(Complete);
        hashCode.Add(Position);
        hashCode.Add(MinuteBefore);
        hashCode.Add(NotificationDate);
        return hashCode.ToHashCode();
    }
}