using Microsoft.AspNetCore.Mvc;
using SolarPower.Models;
using SolarPower.Models.PowerStation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SolarPower.Controllers
{
    public class ExceptionRecordController : MyBaseController<ExceptionRecordController>
    {
        public IActionResult Index()
        {
            return View();
        }

        public ApiResult<List<MyCity>> GetMyCities()
        {
            ApiResult<List<MyCity>> apiResult = new ApiResult<List<MyCity>>();
            try
            {
                apiResult.Code = "0000";
                apiResult.Data = myPowerStationService.GetMyCities(myUser);
            }
            catch (Exception exception)
            {
                apiResult.Code = "9999";
                apiResult.Msg = exception.ToString();
            }

            return apiResult;
        }

        public ApiResult<List<PowerStation>> GetPowerStationByFilter(List<int> cityIds)
        {
            ApiResult<List<PowerStation>> apiResult = new ApiResult<List<PowerStation>>();
            try
            {

                var myPowerStations = myPowerStationService.GetMyPowerStations(myUser,1, cityIds);

                apiResult.Code = "0000";
                apiResult.Data = myPowerStations;
            }
            catch (Exception exception)
            {
                apiResult.Code = "9999";
                apiResult.Msg = exception.ToString();
            }

            return apiResult;
        }
    }
}
