示例#1
0
        private async Task OnUpdate(GuoGuoCommunityContext db, SmallDistrict dto, CancellationToken token = default)
        {
            SmallDistrictIncrementer incrementer = new SmallDistrictIncrementer();

            //公告订阅
            AnnouncementRepository announcementRepository = new AnnouncementRepository();

            announcementRepository.OnSubscribe(incrementer);

            //投票订阅
            VoteRepository voteRepository = new VoteRepository();

            voteRepository.OnSubscribe(incrementer);

            //业委会成员申请表
            VipOwnerApplicationRecordRepository vipOwnerApplicationRecordRepository = new VipOwnerApplicationRecordRepository();

            vipOwnerApplicationRecordRepository.OnSubscribe(incrementer);

            //用户
            UserRepository userRepository = new UserRepository();

            userRepository.OnSubscribe(incrementer);

            await incrementer.OnUpdate(db, dto, token);
        }
 public async void SmallDistrictChanging(GuoGuoCommunityContext dbs, SmallDistrict smallDistrict, CancellationToken token = default)
 {
     using (var db = new GuoGuoCommunityContext())
     {
         await db.Announcements.Where(x => x.SmallDistrictId == smallDistrict.Id.ToString()).UpdateAsync(x => new Announcement {
             SmallDistrictName = smallDistrict.Name
         });
     }
 }
示例#3
0
        public async Task <SmallDistrict> AddAsync(SmallDistrictDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.StreetOfficeId, out var streetOfficeId))
                {
                    throw new NotImplementedException("街道办信息不正确!");
                }
                var streetOffice = await db.StreetOffices.Where(x => x.Id == streetOfficeId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (streetOffice == null)
                {
                    throw new NotImplementedException("街道办信息不存在!");
                }

                if (!Guid.TryParse(dto.CommunityId, out var communityId))
                {
                    throw new NotImplementedException("社区信息不正确!");
                }
                var communities = await db.Communities.Where(x => x.Id == communityId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (communities == null)
                {
                    throw new NotImplementedException("社区办信息不存在!");
                }

                var smallDistricts = await db.SmallDistricts.Where(x => x.Name == dto.Name && x.IsDeleted == false && x.CommunityId == communityId).FirstOrDefaultAsync(token);

                if (smallDistricts != null)
                {
                    throw new NotImplementedException("该小区已存在!");
                }
                var smallDistrict = new SmallDistrict
                {
                    Name   = dto.Name,
                    City   = dto.City,
                    Region = dto.Region,
                    State  = dto.State,
                    CreateOperationTime   = dto.OperationTime,
                    CreateOperationUserId = dto.OperationUserId,
                    LastOperationTime     = dto.OperationTime,
                    LastOperationUserId   = dto.OperationUserId,
                    CommunityId           = communityId,
                    PhoneNumber           = dto.PhoneNumber
                };
                if (!string.IsNullOrWhiteSpace(dto.PropertyCompanyId))
                {
                    if (!Guid.TryParse(dto.PropertyCompanyId, out var propertyCompanyId))
                    {
                        throw new NotImplementedException("物业公司Id信息不正确!");
                    }
                    var propertyCompany = await db.PropertyCompanies.Where(x => x.Id == propertyCompanyId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                    if (propertyCompany == null)
                    {
                        throw new NotImplementedException("物业公司不存在!");
                    }
                    smallDistrict.PropertyCompanyId = propertyCompanyId;
                }
                var entity = db.SmallDistricts.Add(smallDistrict);
                await db.SaveChangesAsync(token);

                return(entity);
            }
        }
示例#4
0
 public async Task OnUpdate(GuoGuoCommunityContext db, SmallDistrict smallDistrict, CancellationToken token = default)//触发事件的方法
        
 {
     await Task.Run(() => SmallDistrictEvent(db, smallDistrict, token));
 }