public async Task <ObjectResultModule> CreateYaeherPatientDoctor([FromBody] YaeherPatientDoctor input) { if (!Commons.CheckSecret(input.Secret)) { this.ObjectResultModule.StatusCode = 422; this.ObjectResultModule.Message = "Wrong Secret"; this.ObjectResultModule.Object = ""; return(this.ObjectResultModule); } var userid = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0; var create = new YaeherPatientDoctor() { UserID = input.UserID, DoctorName = input.DoctorName, DoctorID = input.DoctorID, DoctorJSON = input.DoctorJSON, CreatedBy = userid, CreatedOn = DateTime.Now }; var res = await _PatientDoctorService.CreateYaeherPatientDoctor(create); if (res.Id > 0) { this.ObjectResultModule.StatusCode = 200; this.ObjectResultModule.Message = "sucess"; this.ObjectResultModule.Object = res; } else { this.ObjectResultModule.Object = ""; this.ObjectResultModule.StatusCode = 400; this.ObjectResultModule.Message = "error!"; } #region 操作日志 var CreateYaeherOperList = new YaeherOperList() { OperExplain = "CreateYaeherPatientDoctor", OperContent = JsonHelper.ToJson(input), OperType = "CreateYaeherPatientDoctor", CreatedBy = userid, CreatedOn = DateTime.Now }; var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList); #endregion return(this.ObjectResultModule); }
public async Task <ObjectResultModule> YaeherPatientDoctor([FromBody] YaeherPatientDoctor input) { if (!Commons.CheckSecret(input.Secret)) { this.ObjectResultModule.StatusCode = 422; this.ObjectResultModule.Message = "Wrong Secret"; this.ObjectResultModule.Object = ""; return(this.ObjectResultModule); } var userid = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0; var collectdoctor = await this._PatientDoctorService.YaeherPatientDoctorByExpression(t => t.DoctorID == input.DoctorID && t.CreatedBy == userid); if (collectdoctor != null) { if (!collectdoctor.IsDelete) { collectdoctor.IsDelete = true; collectdoctor.DeleteBy = userid; collectdoctor.DeleteTime = DateTime.Now; var res = await _PatientDoctorService.UpdateYaeherPatientDoctor(collectdoctor); this.ObjectResultModule.Message = "uncollect success"; } else { collectdoctor.IsDelete = false; collectdoctor.DeleteBy = 0; var res = await _PatientDoctorService.UpdateYaeherPatientDoctor(collectdoctor); this.ObjectResultModule.Message = "collect success"; } this.ObjectResultModule.StatusCode = 200; this.ObjectResultModule.Object = ""; } else { var secret = await CreateSecret(); var DocContent = "{\"Id\":" + input.DoctorID.ToString() + ",\"secret\":\"" + secret + "\"}"; var Doctor = await this.PostResponseAsync(Commons.DoctorIp + "api/YaeherDoctorById/", DocContent); var DocResult = JsonHelper.FromJson <APIResult <ResultModule <YaeherDoctorUser> > >(Doctor); if (DocResult == null) { return(new ObjectResultModule("", 204, "NoContent")); } var create = new YaeherPatientDoctor() { UserID = DocResult.result.item.UserID, DoctorName = DocResult.result.item.DoctorName, DoctorID = DocResult.result.item.Id, DoctorJSON = JsonHelper.ToJson(DocResult.result.item), CreatedBy = userid, CreatedOn = DateTime.Now }; var res = await _PatientDoctorService.CreateYaeherPatientDoctor(create); if (res.Id > 0) { this.ObjectResultModule.StatusCode = 200; this.ObjectResultModule.Message = "collect sucess"; this.ObjectResultModule.Object = res; } else { this.ObjectResultModule.Object = ""; this.ObjectResultModule.StatusCode = 400; this.ObjectResultModule.Message = "error!"; } } #region 操作日志 var CreateYaeherOperList = new YaeherOperList() { OperExplain = "YaeherPatientDoctor", OperContent = JsonHelper.ToJson(input), OperType = "YaeherPatientDoctor", CreatedBy = userid, CreatedOn = DateTime.Now }; var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList); #endregion return(this.ObjectResultModule); }