using APT.Infrastructure.Core; using APT.MS.Domain.Entities.SC.PR; using APT.Utility; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; namespace APT.SC.WebApi.Controllers.Api.PRController { /// /// 岗位表单关联表 /// [Route("api/PR/PRPostFormLink")] public partial class PostFormLinkController : AuthorizeApiController { /// /// 新增/编辑 /// /// /// [HttpPost, Route("FullUpdate")] public JsonActionResult FullUpdate([FromBody] T_PR_POST_FORM_LINK entity) { return SafeExecute(() => { var codes = entity.Nav_Codes; if (codes != null && codes.Any()) { codes.ForEach(t => { t.ORG_ID = entity.ORG_ID; t.POST_POST_ID = entity.ID; t.Nav_Form = null; }); } entity.Nav_Codes = null; var departments = entity.Nav_Departments; if (departments != null && departments.Any()) { departments.ForEach(t => { t.ORG_ID = entity.ORG_ID; t.POST_POST_ID = entity.ID; t.Nav_Department = null; }); } entity.Nav_Departments = null; UnifiedCommit(() => { if (entity != null) this.UpdateEntityNoCommit(entity); if (codes != null && codes.Any()) this.BantchSaveEntityNoCommit(codes); if (departments != null && departments.Any()) this.BantchSaveEntityNoCommit(departments); }); return true; }); } /// /// 单条删除 /// /// /// [HttpGet, Route("FullDelete")] public JsonActionResult FullDelete(string id) { return SafeExecute(() => { T_PR_POST_FORM_LINK entity = GetEntity(t => t.ID.ToString() == id, false, "Nav_Codes", "Nav_Departments"); List codeIds = new List(); List departIds = new List(); if (entity.Nav_Codes != null && entity.Nav_Codes.Any()) { var idList = entity.Nav_Codes.Select(t => t.ID).ToList(); codeIds.AddRange(idList); } if (entity.Nav_Departments != null && entity.Nav_Departments.Any()) { var idList = entity.Nav_Departments.Select(t => t.ID).ToList(); departIds.AddRange(idList); } UnifiedCommit(() => { if (codeIds.Any()) this.BantchDeleteEntityNoCommit(codeIds); if (departIds.Any()) this.BantchDeleteEntityNoCommit(departIds); if (entity != null) this.DeleteEntityNoCommit(entity); }); return true; }); } } }