using APT.BaseData.Domain.Entities.OP;
using APT.Infrastructure.Core;
using APT.Utility;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace APT.OP.WebApi.Controllers.Api
{
    [Route("api/OP/OPNotice")]
    public partial class NoticeController : AuthorizeApiController<T_OP_NOTICE>
    {

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost, Route("FullUpdate")]
        public JsonActionResult<bool> FullUpdate([FromBody] T_OP_NOTICE entity)
        {
            return SafeExecute<bool>(() =>
            {
                var noticeDetails = entity.Nav_NoticeDetails;
                entity.Nav_NoticeDetails = null;
                this.UnifiedCommit(() =>
                {
                    this.UpdateEntityNoCommit(entity);
                    if (noticeDetails != null)
                    {
                        this.BantchSaveEntityNoCommit(noticeDetails);
                    }
                });
                return true;
            });
        }

    }
}
