增加人员状态。正常和删除

This commit is contained in:
falcon 2020-12-07 10:32:21 +08:00
parent 9bd424b540
commit d736529df1
3 changed files with 24 additions and 3 deletions

View File

@ -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;
}

View File

@ -0,0 +1,20 @@
using System;
namespace StaffManagement.Database.StaticData
{
/// <summary>
/// 人员状态定义
/// </summary>
[Flags]
public enum PersonStatusDefinition
{
/// <summary>
/// 正常
/// </summary>
Normal = 1,
/// <summary>
/// 删除
/// </summary>
Remove = 2,
}
}

View File

@ -50,6 +50,6 @@ namespace StaffManagement.Database.Tables
/// <summary>
/// 记录状态
/// </summary>
public int Status { get; set; } = 0;
public PersonStatusDefinition Status { get; set; } = PersonStatusDefinition.Normal;
}
}