﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BusinessLogic.VersionControl.Svn
{
    public class SettingsHelper
    {
        public static string ValidateUsername(Dictionary<string, string> settings)
        {
            string userName;

            if (!settings.TryGetValue("Svn.DefaultUsername", out userName))
            {
                throw new KeyNotFoundException("Svn.DefaultUsername");
            }

            return userName;
        }

        public static string ValidatePassword(Dictionary<string, string> settings)
        {
            string password;

            if (!settings.TryGetValue("Svn.DefaultPassword", out password))
            {
                throw new KeyNotFoundException("Svn.DefaultPassword");
            }

            return password;
        }

        public static string ValidateAndReturnSyncWorkingCopyBase(Dictionary<string, string> settings)
        {
            string workingCopyBase;
            
            if (!settings.TryGetValue("Svn.SyncWorkingCopyBasePath", out workingCopyBase))
            {
                throw new KeyNotFoundException("Svn.SyncWorkingCopyBasePath");
            }

            return workingCopyBase;
        }

        public static string ValidateAndReturnMergeWorkingCopyBase(Dictionary<string, string> settings)
        {
            string workingCopyBase;

            if (!settings.TryGetValue("Svn.MergeWorkingCopyBasePath", out workingCopyBase))
            {
                throw new KeyNotFoundException("Svn.MergeWorkingCopyBasePath");
            }

            return workingCopyBase;
        }
    }
}
