using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Authorization;
using System.Threading.Tasks;
using IRaCIS.Application.Services;
using IRaCIS.Core.Application.Service.Inspection.DTO;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Application.Auth;
using Microsoft.Extensions.Localization;

namespace IRaCIS.Core.API.Controllers.Special
{
    //谨慎修改 涉及到财务模块

    [ApiController, Authorize, ApiExplorerSettings(GroupName = "Financial")]
    public class FinancialChangeController : ControllerBase
    {
        private readonly ITrialService _trialService;
   
		private  IStringLocalizer _localizer { get; set; }
		public FinancialChangeController(ITrialService trialService, IStringLocalizer localizer
			)
        {
            _localizer = localizer;
			_trialService = trialService;
          
        }


        //[TrialAudit(AuditType.TrialAudit, AuditOptType.AddOrUpdateTrial)]

        /// <summary> 添加实验项目-返回新增Id[AUTH]</summary>
        /// <returns>新记录Id</returns>
        [HttpPost, Route("Inspection/trial/addOrUpdateTrial")]
        [UnitOfWork]

        public async Task<IResponseOutput> AddOrUpdateTrialInspection(DataInspectionDto<TrialCommand> opt)
        {
            var fun =await AddOrUpdateTrial(opt.Data);
         
            return fun;
        }


        /// <summary> 添加实验项目-返回新增Id[AUTH]</summary>
        /// <param name="param"></param>
        /// <returns>新记录Id</returns>
        [HttpPost, Route("trial/addOrUpdateTrial")]
        //[Authorize(Policy = IRaCISPolicy.PM_APM)]

        [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AddOrUpdateTrial", "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
        public async Task<IResponseOutput<Trial>>  AddOrUpdateTrial(TrialCommand param)
        {
            var userId = Guid.Parse(User.FindFirst("id").Value);
            var result = await _trialService.AddOrUpdateTrial(param);


            return result;
        }


      


    



       



     

      


    

    }
}
