using System.Collections.Generic;

namespace Katteker
{
    /// <summary>
    /// Info about the updates.
    /// </summary>
    public class UpdateInfo
    {
        /// <summary>
        /// Currently installed version.
        /// </summary>
        public ReleaseEntry CurrentlyInstalledVersion { get; }

        /// <summary>
        /// Releases to apply.
        /// </summary>
        public List<ReleaseEntry> ReleasesToApply { get; } = new List<ReleaseEntry>();

        /// <summary>
        /// Constructor
        /// </summary>
        public UpdateInfo(string applicationName, Releases releases)
        {
            CurrentlyInstalledVersion = new ReleaseEntry(applicationName, VersionUtils.GetCurrentVersion());
            foreach (var release in releases)
            {
                if (applicationName.Equals(release.ApplicationName) && release.Version > CurrentlyInstalledVersion.Version)
                {
                    ReleasesToApply.Add(release);
                }
            }
        }
    }
}