Пример #1
0
 public async Task <VipOwnerApplicationRecord> GetForVoteQuestionIdAsync(VipOwnerApplicationRecordDto dto, CancellationToken token = default)
 {
     using (var db = new GuoGuoCommunityContext())
     {
         return(await db.VipOwnerApplicationRecords.Where(x => x.VoteId == dto.VoteId && x.VoteQuestionId == dto.VoteQuestionId).FirstOrDefaultAsync(token));
     }
 }
Пример #2
0
        public async Task UpdateVoteAsync(VipOwnerApplicationRecordDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.Id, out var uid))
                {
                    throw new NotImplementedException("申请记录Id信息不正确!");
                }
                var vipOwnerApplicationRecord = await db.VipOwnerApplicationRecords.Where(x => x.Id == uid && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (vipOwnerApplicationRecord == null)
                {
                    throw new NotImplementedException("该申请记录不存在!");
                }

                vipOwnerApplicationRecord.VoteId               = dto.VoteId;
                vipOwnerApplicationRecord.VoteQuestionId       = dto.VoteQuestionId;
                vipOwnerApplicationRecord.VoteQuestionOptionId = dto.VoteQuestionOptionId;
                vipOwnerApplicationRecord.LastOperationTime    = dto.OperationTime;
                vipOwnerApplicationRecord.LastOperationUserId  = dto.OperationUserId;
                vipOwnerApplicationRecord.IsInvalid            = true;
                vipOwnerApplicationRecord.VipOwnerId           = dto.VipOwnerId;
                vipOwnerApplicationRecord.VipOwnerName         = dto.VipOwnerName;
                await db.SaveChangesAsync(token);
            }
        }
Пример #3
0
 public async Task <List <VipOwnerApplicationRecord> > GetAllInvalidAsync(VipOwnerApplicationRecordDto dto, CancellationToken token = default)
 {
     using (var db = new GuoGuoCommunityContext())
     {
         return(await db.VipOwnerApplicationRecords.Where(x => x.IsInvalid == false && x.IsDeleted == false && x.SmallDistrictId == dto.SmallDistrictId).ToListAsync(token));
     }
 }
Пример #4
0
        public async Task <List <VipOwnerApplicationRecord> > GetAllAsync(VipOwnerApplicationRecordDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                var list = await db.VipOwnerApplicationRecords.Where(x => x.IsDeleted == false).ToListAsync(token);

                if (string.IsNullOrWhiteSpace(dto.SmallDistrictId))
                {
                    var smallDistricts = await db.SmallDistricts.Where(x => x.Community.StreetOfficeId.ToString() == dto.OperationUserStreetOfficeId && x.IsDeleted == false).Select(x => x.Id.ToString()).ToListAsync(token);

                    list = list.Where(x => smallDistricts.Contains(x.SmallDistrictId)).ToList();
                }
                else
                {
                    list = list.Where(x => x.SmallDistrictId == dto.SmallDistrictId).ToList();
                }
                list = list.Where(x => x.CreateOperationTime >= dto.StartTime && x.CreateOperationTime <= dto.EndTime).ToList();
                return(list);
            }
        }
Пример #5
0
 public Task <List <VipOwnerApplicationRecord> > GetListAsync(VipOwnerApplicationRecordDto dto, CancellationToken token = default)
 {
     throw new NotImplementedException();
 }
Пример #6
0
        public async Task <VipOwnerApplicationRecord> AddAsync(VipOwnerApplicationRecordDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.UserId, out var userId))
                {
                    throw new NotImplementedException("用户Id信息不正确!");
                }
                var user = await db.Users.Where(x => x.Id == userId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (user == null)
                {
                    throw new NotImplementedException("用户信息不存在!");
                }

                if (!Guid.TryParse(dto.StructureId, out var structureId))
                {
                    throw new NotImplementedException("申请职能Id信息不正确!");
                }
                var vipOwnerStructure = await db.VipOwnerStructures.Where(x => x.Id == structureId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (vipOwnerStructure == null)
                {
                    throw new NotImplementedException("申请职能不存在!");
                }

                if (!Guid.TryParse(dto.SmallDistrictId, out var smallDistrictId))
                {
                    throw new NotImplementedException("小区Id信息不正确!");
                }
                var smallDistricts = await db.SmallDistricts.Where(x => x.Id == smallDistrictId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (smallDistricts == null)
                {
                    throw new NotImplementedException("小区信息不存在!");
                }

                if (!Guid.TryParse(dto.OwnerCertificationId, out var ownerCertificationId))
                {
                    throw new NotImplementedException("业主认证Id信息不正确!");
                }
                var ownerCertificationRecord = await db.OwnerCertificationRecords.Where(x => x.Id == ownerCertificationId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (ownerCertificationRecord == null)
                {
                    throw new NotImplementedException("业主认证信息不存在!");
                }

                var ownerName = await db.OwnerCertificationRecords.Where(x => x.UserId == dto.UserId && x.Industry.BuildingUnit.Building.SmallDistrictId.ToString() == dto.SmallDistrictId && x.IsDeleted == false).Select(x => x.Owner.Name).FirstOrDefaultAsync(token);

                var vipOwnerApplicationRecord = await db.VipOwnerApplicationRecords.Where(x => x.UserId == dto.UserId && x.IsDeleted == false && x.IsInvalid == false).FirstOrDefaultAsync(token);

                if (vipOwnerApplicationRecord != null)
                {
                    throw new NotImplementedException("您已提交过申请!");
                }

                var entity = db.VipOwnerApplicationRecords.Add(new VipOwnerApplicationRecord
                {
                    Reason                = dto.Reason,
                    StructureId           = dto.StructureId,
                    StructureName         = vipOwnerStructure.Name,
                    UserId                = dto.UserId,
                    CreateOperationTime   = dto.OperationTime,
                    CreateOperationUserId = dto.OperationUserId,
                    SmallDistrictId       = dto.SmallDistrictId,
                    SmallDistrictName     = smallDistricts.Name,
                    LastOperationTime     = dto.OperationTime,
                    Name = ownerName,
                    LastOperationUserId  = dto.OperationUserId,
                    OwnerCertificationId = dto.OwnerCertificationId
                });
                await db.SaveChangesAsync(token);

                return(entity);
            }
        }