Ejemplo n.º 1
0
        public async Task <RelationLabelList> CreateRelationLabelList(RelationLabelList RelationLabelListInfo)
        {
            RelationLabelList relationLabelList = new RelationLabelList();
            // 按照类型、业务ID查询是否存在数据
            var RelationLabelLists = _repository.GetAll().Where(a => a.IsDelete == false && a.BusinessID == RelationLabelListInfo.BusinessID && a.RelationCode == RelationLabelListInfo.RelationCode && a.LableID == RelationLabelListInfo.LableID);

            // 先删除所有业务关联标签
            if (RelationLabelLists.Count() == 0)
            {
                relationLabelList.Id = await _repository.InsertAndGetIdAsync(RelationLabelListInfo);
            }
            return(relationLabelList);
        }
Ejemplo n.º 2
0
 public async Task <string> CreateRelationLabe(RelationLabel RelationLabelListInfo)
 {
     try
     {
         // 按照类型、业务ID查询是否存在数据
         RelationLabelListInfo.AndAlso(a => a.IsDelete == false);
         RelationLabelListInfo.AndAlso(a => a.RelationCode == RelationLabelListInfo.RelationCode);
         RelationLabelListInfo.AndAlso(a => a.BusinessID == RelationLabelListInfo.BusinessID);
         var RelationLabelLists = _repository.GetAll().Where(RelationLabelListInfo.Expression);
         // 先删除所有业务关联标签
         if (RelationLabelLists.Count() > 0)
         {
             foreach (var Item in RelationLabelLists)
             {
                 Item.IsDelete   = true;
                 Item.DeleteBy   = 0;
                 Item.DeleteTime = DateTime.Now;
                 await _repository.UpdateAsync(Item);
             }
         }
         // 再新增相关业务关联标签
         var LableIDList   = RelationLabelListInfo.LableID.Split(',');
         var LableNameList = RelationLabelListInfo.LableName.Split(',');
         if (LableIDList.Length > 0)
         {
             for (int a = 0; a < LableIDList.Length; a++)
             {
                 RelationLabelList relationLabelList = new RelationLabelList();
                 relationLabelList.RelationCode = RelationLabelListInfo.RelationCode;
                 relationLabelList.BusinessID   = RelationLabelListInfo.BusinessID;
                 relationLabelList.BusinessName = RelationLabelListInfo.BusinessName;
                 relationLabelList.LableID      = int.Parse(LableIDList[a].ToString());
                 relationLabelList.LableName    = LableNameList[a].ToString();
                 await _repository.InsertAndGetIdAsync(relationLabelList);
             }
         }
         return("success");
     }
     catch (Exception ex)
     {
         return(ex.ToString());
     }
 }
Ejemplo n.º 3
0
        public async Task <ObjectResultModule> CreateLable([FromBody] LableManage LableManageInfo)
        {
            if (!Commons.CheckSecret(LableManageInfo.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 User = _userManagerService.UserManager(userid);
            var usermanager = JsonHelper.FromJson <UserMemory>(_IabpSession.GetUserData());
            var doctor      = await _yaeherDoctorService.YaeherDoctorByUserID(userid);

            LableManageIn lableManageIn = new LableManageIn();

            lableManageIn.AndAlso(a => !a.IsDelete && a.LableName == LableManageInfo.LableName);
            var LableList = await _lableManageService.LableManageList(lableManageIn);

            DoctorRelation doctorRelation = new DoctorRelation();
            int            LableID        = 0;
            string         LableName      = string.Empty;

            using (var unitOfWork = _unitOfWorkManager.Begin())
            {
                if (LableList.Count() > 0)
                {
                    if ((!usermanager.IsAdmin && usermanager.IsDoctor) || (usermanager.MobileRoleName == "doctor"))
                    {
                        DoctorRelationIn doctorRelationIn = new DoctorRelationIn();
                        doctorRelationIn.AndAlso(a => a.IsDelete == false);
                        doctorRelationIn.AndAlso(a => a.DoctorID == doctor.Id);
                        doctorRelationIn.AndAlso(a => a.LableID == LableList[0].Id);
                        var doctorRelationList = await _doctorRelationService.DoctorClinicRelationList(doctorRelationIn);

                        if (doctorRelationList.Count == 0)
                        {
                            var rel = new DoctorRelation();
                            rel.DoctorName = doctor.DoctorName;
                            rel.DoctorID   = doctor.Id;
                            rel.LableID    = LableList[0].Id;
                            rel.LableName  = LableList[0].LableName;
                            rel.LableJSON  = JsonHelper.ToJson(LableList);
                            rel.CreatedBy  = userid;
                            LableID        = LableList[0].Id;
                            LableName      = LableList[0].LableName;
                            doctorRelation = await _doctorRelationService.CreateDoctorRelation(rel);
                        }
                        else
                        {
                            this.ObjectResultModule.Object     = "";
                            this.ObjectResultModule.StatusCode = 201;
                            this.ObjectResultModule.Message    = "已存在该标签,不用重复提交!";
                        }
                    }
                }
                else
                {
                    var CreateLable = new LableManage()
                    {
                        LableName   = LableManageInfo.LableName,
                        LableRemark = LableManageInfo.LableRemark,
                        OrderSort   = LableManageInfo.OrderSort,
                        CreatedBy   = userid,
                        CreatedOn   = DateTime.Now,
                    };
                    var result = await _lableManageService.CreateLableManage(CreateLable);

                    #region 判断是否为医生  当为医生新建时 绑定给到新医生
                    if ((!usermanager.IsAdmin && usermanager.IsDoctor) || (usermanager.MobileRoleName == "doctor"))
                    {
                        var rel = new DoctorRelation();
                        rel.DoctorName = doctor.DoctorName;
                        rel.DoctorID   = doctor.Id;
                        rel.LableID    = result.Id;
                        rel.LableName  = result.LableName;
                        rel.LableJSON  = JsonHelper.ToJson(result);
                        rel.CreatedBy  = userid;
                        LableID        = result.Id;
                        LableName      = result.LableName;
                        doctorRelation = await _doctorRelationService.CreateDoctorRelation(rel);
                    }
                    #endregion
                    if (result.Id > 0)
                    {
                        this.ObjectResultModule.Object     = result;
                        this.ObjectResultModule.StatusCode = 200;
                        this.ObjectResultModule.Message    = "success";
                    }
                    else
                    {
                        this.ObjectResultModule.Object     = "";
                        this.ObjectResultModule.StatusCode = 400;
                        this.ObjectResultModule.Message    = "error!";
                    }
                }
                #region 增加医生与标签关系
                if ((!usermanager.IsAdmin && usermanager.IsDoctor) || (usermanager.MobileRoleName == "doctor"))
                {
                    RelationLabelList relationLabel = new RelationLabelList();
                    relationLabel.RelationCode = "Doctor";
                    relationLabel.BusinessID   = doctor.Id;
                    relationLabel.BusinessName = doctor.DoctorName;
                    relationLabel.LableID      = LableID;
                    relationLabel.LableName    = LableName;
                    relationLabel.CreatedBy    = userid;
                    relationLabel.CreatedOn    = DateTime.Now;
                    var Lableresul = await _relationLabelListService.CreateRelationLabelList(relationLabel);
                }
                #endregion
                #region 操作日志
                var CreateYaeherOperList = new YaeherOperList()
                {
                    OperExplain = "CreateLable",
                    OperContent = JsonHelper.ToJson(LableManageInfo),
                    OperType    = "CreateLable",
                    CreatedBy   = userid,
                    CreatedOn   = DateTime.Now
                };
                var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

                #endregion
                unitOfWork.Complete();
            }
            return(ObjectResultModule);
        }
Ejemplo n.º 4
0
 public async Task <RelationLabelList> DeleteRelationLabelList(RelationLabelList RelationLabelListInfo)
 {
     return(await _repository.UpdateAsync(RelationLabelListInfo));
 }