﻿
using OpenLearningPlayer.Shared.Domain;
using OpenLearningPlayer.Shared.ViewModels;
using WebCommunicationSharedStructures.WebStuctures;

namespace OpenLearningPlayer.Shared.TheStore
{
    public class StoreItemExt : StoreItem
    {
        public bool isInstalled;
        public LearningItem LearningItem;
        public string   CoverFileFullPath { get; set; }

        public MultiStateButton_Model DownloadButton { get { return _DownloadButton; } set { Set(ref _DownloadButton, value); } }  private MultiStateButton_Model _DownloadButton;

        public StoreItemExt() : base(){
            DownloadButton = new MultiStateButton_Model();
        }

        public void UpdateDownloadButtonStatus()
        {
            // Download a new element state
            if (LearningItem == null)
            {
                DownloadButton.State1 = true;
            } else
            {
                // Update element
                if (LearningItem.Version < Version) DownloadButton.State2 = true;

                // no needs any action
                if (LearningItem.Version == Version) DownloadButton.Visibility = VisualState.Hidden;
            }
        }
    }

}
