using PlantBox.Client.Resources;
using System;
using System.Collections.Generic;
using System.Text;

namespace PlantBox.Client.Models
{
    public class Duration
    {
        public uint Multiplier { get; }
        public Interval Interval { get; }

        public Duration(uint multiplier, Interval interval)
        {
            Multiplier = multiplier;
            Interval = interval;
        }

        private string IntervalToString(Interval interval)
        {
            switch (interval)
            {
                case Interval.Hourly:
                    return Locale.Hour;
                case Interval.Daily:
                    return Locale.Day;
                case Interval.Weekly:
                    return Locale.Week;
                case Interval.Monthly:
                    return Locale.Month;
                case Interval.Yearly:
                    return Locale.Year;
                default:
                    return "Invalid interval";
            }
        }

        public override string ToString()
        {
            return $"{Multiplier} {IntervalToString(Interval)}{(Multiplier > 1  && !IntervalToString(Interval).EndsWith("s") ? "s" : "")}";
        }
    }
}
