using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.DM;
using APT.Utility;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace APT.SC.WebApi.Controllers.Api.DMController
{
    [Route("api/DM/DMTimeRun")]
    public partial class TimeRunController : AuthorizeApiController<T_DM_TIME_RUN>
    {
        /// <summary>
        /// 新增/编辑
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost, Route("FullUpdate")]
        public JsonActionResult<bool> FullUpdate([FromBody] T_DM_TIME_RUN entity)
        {
            return SafeExecute(() =>
            {
                var details = entity.Nav_Contents;
                entity.Nav_Contents = null;
                UnifiedCommit(() =>
                {
                    if (entity != null)
                        this.UpdateEntityNoCommit(entity);
                    if (details != null && details.Any())
                        this.BantchSaveEntityNoCommit(details);
                });
                return true;
            });
        }
    }
}
