Exemple #1
0
        // 更新模板样品ids(根据UserId)
        public Dtos.HtmlDataOperRetDto PostAddOrUpdateTplSpecByTplIdAndUserId(int tplId, string specIds, long uid)
        {
            var item = this._uTplSpecimenRepository.GetAll().Where(x => x.UserId == uid && x.TplId == tplId).SingleOrDefault();

            if (item == null)
            {
                if (specIds != "-1")
                {
                    UserTplSpecimens tmpItem = new UserTplSpecimens();
                    tmpItem.UserId      = uid;
                    tmpItem.TplId       = tplId;
                    tmpItem.SpecimenIds = specIds;
                    tmpItem.IsDeleted   = false;
                    this._uTplSpecimenRepository.Insert(tmpItem);
                }
            }
            else
            {
                if (specIds != "-1")
                {
                    item.SpecimenIds = specIds;
                    this._uTplSpecimenRepository.Update(item);
                }
                else
                {
                    this._uTplSpecimenRepository.Delete(item);
                }
            }

            return(new Dtos.HtmlDataOperRetDto()
            {
                Code = 1,
                Message = "操作成功!"
            });
        }
Exemple #2
0
        // 更新或者保存样品
        public Dtos.HtmlDataOperRetDto PostAddOrUpdateSingleTplSpec(TplSpecDto specItem)
        {
            long userId      = AbpSession.UserId ?? 0;
            var  tplSpecList = _uTplSpecimenRepository.GetAll().Where(x => x.UserId == userId).ToList();

            var tmpUserTplSpec = tplSpecList.Where(x => x.TplId == int.Parse(specItem.TplId)).SingleOrDefault();

            if (tmpUserTplSpec != null)
            {
                tmpUserTplSpec.SpecimenIds = specItem.SpecIds;
                _uTplSpecimenRepository.Update(tmpUserTplSpec);
            }
            else
            {
                UserTplSpecimens insertSpec = new UserTplSpecimens();
                insertSpec.UserId      = userId;
                insertSpec.TplId       = int.Parse(specItem.TplId);
                insertSpec.SpecimenIds = specItem.SpecIds;
                insertSpec.IsDeleted   = false;
                _uTplSpecimenRepository.Insert(insertSpec);
            }

            return(new Dtos.HtmlDataOperRetDto()
            {
                Code = 1,
                Message = "操作成功!"
            });
        }
Exemple #3
0
        // 更新用户模板样品
        private void UpdateUserTplSpecimen(List <TplSpecimenDto> specimenList, long userId)
        {
            // 删除原有的样品信息
            var userRep = this._uTplSpecimenRepository.GetAll().Where(x => x.UserId == userId);

            foreach (var item in userRep)
            {
                this._uTplSpecimenRepository.Delete(item);
            }
            // 如果specimenList.Count()为空,则证明没有样品权限,不处理即可
            if (specimenList.Count() > 0)
            {
                // 添加新的
                foreach (var item in specimenList)
                {
                    UserTplSpecimens utpl = new UserTplSpecimens();
                    utpl.UserId      = userId;
                    utpl.TplId       = item.TplId;
                    utpl.SpecimenIds = string.Join(",", item.SpecimenIds);
                    utpl.IsDeleted   = false;
                    this._uTplSpecimenRepository.Insert(utpl);
                }
            }
        }
Exemple #4
0
        // 更新整个用户权限
        public Dtos.HtmlDataOperRetDto PostAddOrUpdateUserOrg(UserDataDto input)
        {
            long              thisUserId = AbpSession.UserId ?? 0;
            string            orgIds     = input.OrgIds;
            string            tplIds     = input.TplIds;
            List <TplSpecDto> specList   = input.TplSpecList;

            // 修改UserOrg
            if (!string.IsNullOrEmpty(orgIds))
            {
                var userOrg = _uUserOrgRepository.GetAll().Where(x => x.UserId == thisUserId).SingleOrDefault();
                if (userOrg == null)
                {
                    UserOrg tmpUserOrg = new UserOrg();
                    tmpUserOrg.OrgIds    = orgIds;
                    tmpUserOrg.UserId    = thisUserId;
                    tmpUserOrg.IsDeleted = false;
                    _uUserOrgRepository.Insert(tmpUserOrg);
                }
                else
                {
                    userOrg.OrgIds = orgIds;
                    _uUserOrgRepository.Update(userOrg);
                }
            }

            // 修改UserTpl
            if (!string.IsNullOrEmpty(tplIds))
            {
                var userTpl = _utplRepository.GetAll().Where(x => x.UserId == thisUserId).SingleOrDefault();
                if (userTpl == null)
                {
                    UserTpl tmpUserTpl = new UserTpl();
                    tmpUserTpl.UserId    = thisUserId;
                    tmpUserTpl.TplIds    = tplIds;
                    tmpUserTpl.IsDeleted = false;
                    _utplRepository.Insert(tmpUserTpl);
                }
                else
                {
                    userTpl.TplIds = tplIds;
                    _utplRepository.Update(userTpl);
                }
            }


            // 修改UserTplSpec
            if (specList != null && specList.Count > 0)
            {
                var tplSpecList = _uTplSpecimenRepository.GetAll().Where(x => x.UserId == thisUserId).ToList();
                foreach (var specItem in specList)
                {
                    var tmpUserTplSpec = tplSpecList.Where(x => x.TplId == int.Parse(specItem.TplId)).SingleOrDefault();
                    if (tmpUserTplSpec != null)
                    {
                        tmpUserTplSpec.SpecimenIds = specItem.SpecIds;
                        _uTplSpecimenRepository.Update(tmpUserTplSpec);
                    }
                    else
                    {
                        UserTplSpecimens insertSpec = new UserTplSpecimens();
                        insertSpec.UserId      = thisUserId;
                        insertSpec.TplId       = int.Parse(specItem.TplId);
                        insertSpec.SpecimenIds = specItem.SpecIds;
                        insertSpec.IsDeleted   = false;
                        _uTplSpecimenRepository.Insert(insertSpec);
                    }
                }
            }

            return(new Dtos.HtmlDataOperRetDto()
            {
                Code = 1,
                Message = "操作成功!"
            });
        }