internal BackupRestoreView.FrequencyBasedBackupSchedule ToFrequencyBasedBackupScheduleView()
        {
            // from BackupScheduleInterval to Timespan
            TimeSpan timespan;

            if (this.IntervalType == BackupScheduleInterval.Minutes)
            {
                timespan = TimeSpan.FromMinutes(this.Interval);
            }
            else
            {
                timespan = TimeSpan.FromHours(this.Interval);
            }

            var frequencyBasedSchedulePolicyView =
                new BackupRestoreView.FrequencyBasedBackupSchedule
            {
                Interval = timespan,
            };

            return(frequencyBasedSchedulePolicyView);
        }
        internal static FrequencyBasedBackupSchedule FromFrequencyBasedBackupScheduleView(
            BackupRestoreView.FrequencyBasedBackupSchedule frequencyBasedBackupScheduleView)
        {
            //from TimeSpan to BackupScheduleInterval.
            TimeSpan timespan = frequencyBasedBackupScheduleView.Interval;
            BackupScheduleInterval intervalType;
            int interval;

            if (timespan > TimeSpan.FromDays(maximumTimeIntervalInDays))
            {
                throw new ArgumentException(StringResources.InvalidBackupInterval);
            }

            if (timespan.Minutes != 0)
            {
                intervalType = BackupScheduleInterval.Minutes;
                interval     = (int)timespan.TotalMinutes;
            }
            else if (timespan.TotalHours != 0)
            {
                intervalType = BackupScheduleInterval.Hours;
                interval     = (int)timespan.TotalHours;
            }
            else
            {
                throw new ArgumentException(StringResources.InvalidInterval);
            }

            var frequencyBasedBackupSchedule = new FrequencyBasedBackupSchedule
            {
                IntervalType = intervalType,
                Interval     = interval
            };

            return(frequencyBasedBackupSchedule);
        }