using APT.BaseData.Domain.Entities.BD;
using APT.Infrastructure.Core;
using APT.Utility;
using Microsoft.AspNetCore.Mvc;
using System;

namespace APT.BD.WebApi.Controllers.Api
{
    [Route("api/BD/BDReductionFactor")]
    public partial class ReductionFactorController : AuthorizeApiController<T_BD_REDUCTION_FACTOR>
    {
        /// <summary>
        /// 重置数值
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost, Route("ResetValue")]
        public JsonActionResult<bool> FullUpdate(string id)
        {
            return SafeExecute<bool>(() =>
            {
                var entity = this.GetEntity<T_BD_REDUCTION_FACTOR>(id);
                if (entity != null)
                {
                    entity.CUR_VALUE = entity.REF_VALUE;
                    this.UpdateEntity(entity);
                }
                else
                {
                    throw new Exception("查无此折标系数！");
                }
                return true;
            });
        }
    }
}
