using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.FO;
using APT.MS.Domain.Entities.HM;
using APT.MS.Domain.Entities.SC.BI;
using APT.Utility;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace APT.FO.WebApi.Controllers
{
    [Route("api/FO/FOHolidays")]
    public partial class HolidaysController : AuthorizeApiController<T_FO_HOLIDAYS>
    {
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost, Route("FullUpdate")]
        public JsonActionResult<bool> FullUpdate([FromBody] T_FO_HOLIDAYS entity)
        {
            return SafeExecute<bool>(() =>
            {
                var details = entity.Nav_Details;
                entity.Nav_Details = null;
                this.UnifiedCommit(() =>
                {
                    if (entity != null)
                        UpdateEntityNoCommit(entity);
                    if (details != null && details.Any())
                        BantchSaveEntityNoCommit(details);
                });
                return true;
            });
        }
    }
}
