using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using wispro.sp.share;

namespace wispro.sp.web.Services
{
    public class ReportService
    {
        private readonly IHttpService _httpClient;

        public ReportService(IHttpService httpClient)
        {
            _httpClient = httpClient;
        }
        public async Task<ChartDatas> GetAppealReportData(int type,DateTime? start,DateTime? end,int? userId)
        {
            //AppealReport(int type, DateTime ? start, DateTime ? end, int ? userId)

            string strUrl = $"Report/AppealReport?type={type}";
            if (start.HasValue)
            {
                strUrl = $"{strUrl}&start={start?.ToString("yyyy-MM-dd")}";
            }

            if (end.HasValue)
            {
                strUrl = $"{strUrl}&end={end?.ToString("yyyy-MM-dd")}";
            }

            if (userId.HasValue)
            {
                strUrl = $"{strUrl}&userId={userId.Value}";
            }
            var data = await _httpClient.Get<share.ChartDatas>(strUrl);
            return data;
        }

        public async Task<ChartDatas> GetStaticReportData(int iType)
        {
            int i = 0;
            bool isYear = false;
            switch (iType)
            {
                case 0:
                    i = 0;
                    break;
                case 2:
                    i = 0;
                    isYear = true;
                    break;
                case 1:
                    i = 1;
                    break;
                case 3:
                    i = 1;
                    isYear = true;
                    break;
                case 4:
                    i = 2;
                    break;

            }
            string strUrl = $"Report/StaticsReport?type={i}&isYear={isYear}";
            
            var data = await _httpClient.Get<share.ChartDatas>(strUrl);
            return data;
        }
    }
}
