﻿using MotorPremiumCalculator.Business.Interfaces;
using MotorPremiumCalculator.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MotorPremiumCalculator.Repository.Interfaces;
using MotorPremiumCalculator.Repository.Implementations;

namespace MotorPremiumCalculator.Business.Implementations
{
    public class CommonService : ICommonService
    {
        ICommonRepository commonRepository;

        public CommonService(string dbpath)
        {
            commonRepository = new CommonRepository(dbpath);
        }

        /// <summary>
        /// Gets the list of zones based on vechicle types namely 1 or 2
        /// </summary>
        /// <param name="vechicleType">Type of vechicle : 1 or 2</param>
        /// <returns>List of zones</returns>
        public List<Zone> GetZones(int vechicleType)
        {
            List<Zone> zones = new List<Zone>();
            try
            {
                switch (vechicleType)
                {
                    case 1:
                        zones = commonRepository.GetZones();
                        break;
                    case 2:
                        zones = commonRepository.GetZones();
                        zones.RemoveAt(2);
                        break;
                }

                return zones;
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// Gets the Pa to pillion rider amount for two wheeler
        /// </summary>
        /// <returns>Pa to Pillion Rider amount</returns>
        public List<PaToPillionRiderAmount> GetPaToPillionRiderAmount()
        {
            return commonRepository.GetPaToPillionRiderAmount();
        }
    }
}
