public JsonResult GetById([FromForm] string token, [FromForm] int caseId) { DataResult dr = new DataResult(); try { CaseBLL caseBLL = new CaseBLL(); CaseEntity caseEntity = caseBLL.GetById(caseId); CommentBLL commentBLL = new CommentBLL(); caseEntity.commentCount = commentBLL.ListByTypeAndObjId((int)Entity.TypeEnumEntity.TypeEnum.案例, caseEntity.caseId).Count(); EndorseBLL endorseBLL = new EndorseBLL(); List <EndorseEntity> endorseEntities = endorseBLL.ListByTypeAndObjId((int)Entity.TypeEnumEntity.TypeEnum.案例, caseEntity.caseId); caseEntity.endorseCount = endorseEntities.Count(); UserEntity userEntity = new UserEntity(); if (!string.IsNullOrWhiteSpace(token)) { userEntity = this.GetUserByToken(token); if (endorseEntities.ToList().Exists(it => it.userId == userEntity.userId)) { caseEntity.isEndorse = true; } } CaseStepBLL caseStepBLL = new CaseStepBLL(); caseEntity.caseStepEntities = caseStepBLL.ListByCaseId(caseEntity.caseId); CaseTagCorrelationBLL caseTagCorrelationBLL = new CaseTagCorrelationBLL(); caseEntity.caseTagEntities = caseTagCorrelationBLL.CaseTagListByCaseId(caseEntity.caseId); dr.code = "200"; dr.data = caseEntity; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }
public JsonResult GetById([FromForm] string token, [FromForm] int shareId) { DataResult dr = new DataResult(); try { ShareEntity shareEntity = shareBLL.GetById(shareId); UserEntity userEntity = new UserEntity(); CommentBLL commentBLL = new CommentBLL(); shareEntity.commentCount = commentBLL.ListByTypeAndObjId((int)Entity.TypeEnumEntity.TypeEnum.说说, shareEntity.shareId).Count(); EndorseBLL endorseBLL = new EndorseBLL(); List <EndorseEntity> endorseEntities = endorseBLL.ListByTypeAndObjId((int)Entity.TypeEnumEntity.TypeEnum.说说, shareEntity.shareId); shareEntity.endorseCount = endorseEntities.Count(); if (!string.IsNullOrWhiteSpace(token)) { userEntity = this.GetUserByToken(token); if (endorseEntities.ToList().Exists(it => it.userId == userEntity.userId)) { shareEntity.isEndorse = true; } } dr.code = "200"; dr.data = shareEntity; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }