/// <summary> /// 根据ID获取角色 /// </summary> /// <param name="keyWord"></param> /// <returns></returns> public Role Get(string id) { using (DbContext db = new CRDatabase()) { CTMS_SYS_ROLE entity = db.Set <CTMS_SYS_ROLE>().Find(id); if (entity == null || string.IsNullOrEmpty(entity.ROLEID)) { return(null); } return(EntityToModel(entity)); } }
private Role EntityToModel(CTMS_SYS_ROLE entity) { if (entity == null) { return(null); } return(new Role() { RoleID = entity.ROLEID, RoleName = entity.ROLENAME, SystemCategory = entity.SYSTEMCATEGORY, Remark = entity.REMARK, CreateDateTime = entity.CREATEDATETIME, CreateUserID = entity.CREATEUSERID, CreateUserName = entity.CREATEUSERNAME, EditTime = entity.EDITDATETIME, EditUserID = entity.EDITUSERID, EditUserName = entity.EDITUSERNAME, OwnerID = entity.OWNERID, OwnerName = entity.OWNERNAME, IsDeleted = entity.ISDELETED }); }