﻿using BookReviews.Domain.MembershipRebootCustomizationObjects;
using BrockAllen.MembershipReboot;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BookReviews.Domain
{
    //public class LinkedAccountClaimAdapter
    //{
    //    private LinkedAccountClaimCustomized linkedAccountClaimCustomized = null;

    //    public LinkedAccountClaimAdapter()
    //    {
    //        linkedAccountClaimCustomized = new LinkedAccountClaimCustomized();
    //    }

    //    public LinkedAccountClaimAdapter(LinkedAccountClaim linkedAccountClaim)
    //    {
    //        linkedAccountClaimCustomized = (LinkedAccountClaimCustomized)linkedAccountClaim;
    //    }

    //    //public virtual LinkedAccountClaimAdapterPK Id { get; protected internal set; }

    //    public virtual string ProviderAccountID { get { return linkedAccountClaimCustomized.ProviderAccountID; } protected internal set { linkedAccountClaimCustomized.ProviderAccountID = value; } }
    //    public virtual string ProviderName { get { return linkedAccountClaimCustomized.ProviderName; } protected internal set { linkedAccountClaimCustomized.ProviderName = value; } }
    //    public virtual string Type { get { return linkedAccountClaimCustomized.Type; } protected internal set { linkedAccountClaimCustomized.Type = value; } }
    //    public virtual Guid UserAccountID { get { return linkedAccountClaimCustomized.UserAccountID; } protected internal set { linkedAccountClaimCustomized.UserAccountID = value; } }
    //    public virtual string Value { get { return linkedAccountClaimCustomized.Value; } protected internal set { linkedAccountClaimCustomized.Value = value; } }
    //    public virtual LinkedAccountAdapter LinkedAccount { get { return new LinkedAccountAdapter(linkedAccountClaimCustomized.LinkedAccount); } set { linkedAccountClaimCustomized.LinkedAccount = new LinkedAccountCustomized(value); } }

    //    public override bool Equals(object obj)
    //    {
    //        // as zwraca typowany obiekt albo null jezeli nie moze dokonac poprawnego rzutowania
    //        // dlatego nie trzeba sprawdzac obj == null
    //        LinkedAccountClaimAdapter typedObj = obj as LinkedAccountClaimAdapter;

    //        if (typedObj == null)
    //        {
    //            return false;
    //        }

    //        if (UserAccountID == typedObj.UserAccountID
    //            && ProviderName == typedObj.ProviderName
    //            && ProviderAccountID == typedObj.ProviderAccountID
    //            && Type == typedObj.Type
    //            && Value == typedObj.Value)
    //        {
    //            return true;
    //        }

    //        return false;
    //    }

    //    public override int GetHashCode()
    //    {
    //        return (UserAccountID + "|" + ProviderName + "|" + ProviderAccountID + "|" + Type + "|" + Value).GetHashCode();
    //    }
    //}

    public class LinkedAccountClaimAdapter : LinkedAccountClaim
    {
        public LinkedAccountClaimAdapter()
        {
        }

        public LinkedAccountClaimAdapter(LinkedAccountClaim linkedAccountClaim)
        {
            //LinkedAccount = new LinkedAccountAdapter(linkedAccountClaim.LinkedAccount);
            ProviderAccountID = linkedAccountClaim.ProviderAccountID;
            ProviderName = linkedAccountClaim.ProviderName;
            Type = linkedAccountClaim.Type;
            UserAccountID = linkedAccountClaim.UserAccountID;
            Value = linkedAccountClaim.Value;
        }

        ////public virtual LinkedAccountClaimAdapterPK Id { get; protected internal set; }

        //public virtual new string ProviderAccountID { get; protected internal set; }
        //public virtual new string ProviderName { get; protected internal set; }
        //public virtual new string Type { get; protected internal set; }
        //public virtual new Guid UserAccountID { get; protected internal set; }
        //public virtual new string Value { get; protected internal set; }
        public virtual new LinkedAccountAdapter LinkedAccount { get { return new LinkedAccountAdapter(base.LinkedAccount); } protected internal set { base.LinkedAccount = value; } }

        public override bool Equals(object obj)
        {
            // as zwraca typowany obiekt albo null jezeli nie moze dokonac poprawnego rzutowania
            // dlatego nie trzeba sprawdzac obj == null
            LinkedAccountClaimAdapter typedObj = obj as LinkedAccountClaimAdapter;

            if (typedObj == null)
            {
                return false;
            }

            if (UserAccountID == typedObj.UserAccountID
                && ProviderName == typedObj.ProviderName
                && ProviderAccountID == typedObj.ProviderAccountID
                && Type == typedObj.Type
                && Value == typedObj.Value)
            {
                return true;
            }

            return false;
        }

        public override int GetHashCode()
        {
            return (UserAccountID + "|" + ProviderName + "|" + ProviderAccountID + "|" + Type + "|" + Value).GetHashCode();
        }
    }
}
