增加人员状态。正常和删除
This commit is contained in:
		
							parent
							
								
									9bd424b540
								
							
						
					
					
						commit
						d736529df1
					
				@ -6,6 +6,7 @@ using Falcon.Extend;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
using Microsoft.EntityFrameworkCore;
 | 
			
		||||
using Microsoft.Extensions.Logging;
 | 
			
		||||
using StaffManagement.Database.StaticData;
 | 
			
		||||
using StaffManagement.Database.Tables;
 | 
			
		||||
using StaffManagement.Models;
 | 
			
		||||
 | 
			
		||||
@ -56,8 +57,8 @@ namespace StaffManagement.Controllers.Api
 | 
			
		||||
        [ProducesResponseType(typeof(bool),200)]
 | 
			
		||||
        public bool RemovePerson(int id) {
 | 
			
		||||
            var p = new Person { Id = id };
 | 
			
		||||
            //this.Db.People.Attach(p);
 | 
			
		||||
            this.Db.Entry(p).State = EntityState.Deleted;
 | 
			
		||||
            this.Db.People.Attach(p);
 | 
			
		||||
            p.Status = PersonStatusDefinition.Remove;
 | 
			
		||||
            this.Db.SaveChanges();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,20 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace StaffManagement.Database.StaticData
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 人员状态定义
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Flags]
 | 
			
		||||
    public enum PersonStatusDefinition
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 正常
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Normal = 1,
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 删除
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Remove = 2,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -50,6 +50,6 @@ namespace StaffManagement.Database.Tables
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 记录状态
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Status { get; set; } = 0;
 | 
			
		||||
        public PersonStatusDefinition Status { get; set; } = PersonStatusDefinition.Normal;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user