using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace FLY.Thick.FilmCasting.WebAPI.Controllers
{
    /// <summary>
    /// AD曲线
    /// </summary>
    public class CurveController : ApiController
    {
        ICurveService curveService;

        /// <summary>
        /// 
        /// </summary>
        public CurveController(
           ICurveService curveService
            )
        {
            this.curveService = curveService;
        }
        /// <summary>
        /// 获取服务的参数及状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Data GetValue()
        {

            return new Data()
            {
                CorrectWay = curveService.CorrectWay,
                Flag = curveService.Flag,
                Curves = curveService.Curves
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        [HttpPost]
        public void Apply([FromBody] ApplyRequest data) 
        {
            curveService.Apply(data.correctWay, data.flag, data.curves);
        }
        public class ApplyRequest 
        {
            /// <summary>
            /// AD曲线校正方式 比例放大 / 平移
            /// </summary>
            public CurveCorrectWay correctWay { get; set; }

            /// <summary>
            /// 标记，用于告诉 客户端，当前的曲线类型， 自然对数 / 直线拟合 / 二次拟合
            /// </summary>
            public CurveType flag { get; set; }

            /// <summary>
            /// AD曲线
            /// </summary>
            public CurveCell2[] curves { get; set; }
        }
        public class Data 
        {
            /// <summary>
            /// AD曲线校正方式  比例放大 / 平移
            /// </summary>
            public CurveCorrectWay CorrectWay { get; set; }
            /// <summary>
            /// 标记，用于告诉 客户端，当前的曲线类型， 自然对数 / 直线拟合 / 二次拟合
            /// </summary>
            public CurveType Flag { get; set; }
            /// <summary>
            /// 曲线
            /// </summary>
            public CurveCell[] Curves { get; set; }
        }
    }
}
