示例#1
0
        public void UpdatePointGroup(PlatformPointGroupDataObject dataObject)
        {
            dataObject.CreateDate      = DateTime.Now;
            dataObject.OperatorAccount = AuthManager.GetCurrentUser().OperatorAccount;
            PlatformPointGroup pointGroup = this.platformPointGroupRepository.FindAll(p => p.ID.Equals(dataObject.ID)).FirstOrDefault();

            if (pointGroup == null)
            {
                throw new CustomException(505, "修改组不存在");
            }
            AutoMapper.Mapper.Map <PlatformPointGroupDataObject, PlatformPointGroup>(dataObject, pointGroup);
            this.unitOfWorkRepository.PersistUpdateOf(pointGroup);
            this.unitOfWork.Commit();
            if (!string.IsNullOrWhiteSpace(pointGroup.Code))
            {
                var codeArray = pointGroup.Code.Split(',');
                var list      = this.businessmanRepository.FindAll().OfType <Carrier>().Where(p => codeArray.Contains(p.Code) || p.PointGroupID == pointGroup.ID).ToList();
                foreach (var item in list)
                {
                    if (codeArray.Contains(item.Code))
                    {
                        item.PointGroupID = pointGroup.ID;
                    }
                    else
                    {
                        item.PointGroupID = null;
                    }
                    systemUnitOfWorkRepository.PersistUpdateOf(item);
                }
                systemUnitOfWork.Commit();
            }
        }
示例#2
0
        public void AddPointGroup(PlatformPointGroupDataObject dataObject)
        {
            var count = platformPointGroupRepository.FindAll(p => p.GroupName == dataObject.GroupName).Count();

            if (count > 0)
            {
                throw new CustomException(505, "扣点组名称重复");
            }
            PlatformPointGroup pointGroup = AutoMapper.Mapper.Map <PlatformPointGroupDataObject, PlatformPointGroup>(dataObject);

            pointGroup.CreateDate      = DateTime.Now;
            pointGroup.OperatorAccount = AuthManager.GetCurrentUser().OperatorAccount;
            this.unitOfWorkRepository.PersistCreationOf(pointGroup);
            this.unitOfWork.Commit();
            if (!string.IsNullOrWhiteSpace(pointGroup.Code))
            {
                var codeArray = pointGroup.Code.Split(',');
                var list      = this.businessmanRepository.FindAll(p => codeArray.Contains(p.Code)).OfType <Carrier>().ToList();
                foreach (var item in list)
                {
                    item.PointGroupID = pointGroup.ID;
                    systemUnitOfWorkRepository.PersistUpdateOf(item);
                }
                systemUnitOfWork.Commit();
            }
        }