/// <summary> /// 根据ID获取用户基因信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public UserGene Get(string id) { if (string.IsNullOrEmpty(id)) { LogService.WriteInfoLog(logTitle, "试图查找ID为空的UserGene实体!"); return(null); } using (DbContext db = new CRDatabase()) { HR_USERGENE entity = db.Set <HR_USERGENE>().Find(id); if (entity == null) { return(null); } return(EntityToModel(entity)); } }
/// <summary> /// 删除用户基因 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Delete(string id) { if (string.IsNullOrEmpty(id)) { LogService.WriteInfoLog(logTitle, "试图删除ID为空的UserGene实体!"); return(false); } using (DbContext db = new CRDatabase()) { HR_USERGENE entity = db.Set <HR_USERGENE>().Find(id); if (entity != null) { db.Set <HR_USERGENE>().Remove(entity); } return(db.SaveChanges() > 0); } }
private UserGene EntityToModel(HR_USERGENE entity) { if (entity == null) { return(null); } return(new UserGene() { ID = entity.ID, UserID = entity.USERID, GeneID = entity.GENEID, Allele1ID = entity.ALLELE1ID, Allele2ID = entity.ALLELE2ID, CreateBy = entity.CREATEBY, CreateTime = entity.CREATETIME, ModifyBy = entity.MODIFYBY, ModifyTime = entity.MODIFYTIME, CopyNumber1 = entity.COPYNUMBER1, CopyNumber2 = entity.COPYNUMBER2 }); }