Ejemplo n.º 1
0
        public async Task <VipOwner> AddAsync(VipOwnerDto dto, CancellationToken token = default)
        {
            //TODO检查是否存在未竞选业委会信息
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.SmallDistrictId, out var smallDistrictId))
                {
                    throw new NotImplementedException("小区信息不正确!");
                }
                var smallDistrict = await db.SmallDistricts.Where(x => x.Id == smallDistrictId && x.IsDeleted == false).FirstOrDefaultAsync(token);

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

                var entity = db.VipOwners.Add(new VipOwner
                {
                    Name                  = smallDistrict.Name + dto.Name,
                    RemarkName            = dto.RemarkName,
                    SmallDistrictId       = smallDistrictId,
                    CreateOperationTime   = dto.OperationTime,
                    CreateOperationUserId = dto.OperationUserId,
                    LastOperationTime     = dto.OperationTime,
                    LastOperationUserId   = dto.OperationUserId
                });
                await db.SaveChangesAsync(token);

                return(entity);
            }
        }
Ejemplo n.º 2
0
        public async Task UpdateAsync(VipOwnerDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.Id, out var uid))
                {
                    throw new NotImplementedException("业委会Id信息不正确!");
                }
                var vipOwner = await db.VipOwners.Where(x => x.Id == uid).FirstOrDefaultAsync(token);

                if (vipOwner == null)
                {
                    throw new NotImplementedException("该业委会不存在!");
                }
                //var entity = await db.VipOwners.Where(x => x.Name == dto.Name && x.IsDeleted == false && x.SmallDistrictId == dto.SmallDistrictId && x.Id != uid).FirstOrDefaultAsync(token);
                //if (entity != null)
                //{
                //    throw new NotImplementedException("该业委会已存在!");
                //}
                vipOwner.RemarkName          = dto.RemarkName;
                vipOwner.LastOperationTime   = dto.OperationTime;
                vipOwner.LastOperationUserId = dto.OperationUserId;
                await OnUpdateAsync(db, vipOwner, token);

                await db.SaveChangesAsync(token);
            }
        }
Ejemplo n.º 3
0
 public async Task <List <VipOwner> > GetListAsync(VipOwnerDto dto, CancellationToken token = default)
 {
     using (var db = new GuoGuoCommunityContext())
     {
         return(await db.VipOwners.Where(x => x.IsDeleted == false && x.SmallDistrictId.ToString() == dto.SmallDistrictId && x.IsValid == false && x.IsElection == false).ToListAsync(token));
     }
 }
Ejemplo n.º 4
0
        public async Task <List <VipOwner> > GetListForStreetOfficeIdAsync(VipOwnerDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                var streetOfficeList = await db.SmallDistricts.Where(x => x.Community.StreetOfficeId.ToString() == dto.StreetOfficeId).Select(x => x.Id).ToListAsync(token);

                return(await db.VipOwners.Where(x => streetOfficeList.Contains(x.Id)).ToListAsync(token));
            }
        }
Ejemplo n.º 5
0
 public async Task <List <VipOwner> > GetIsValidAsync(VipOwnerDto dto, CancellationToken token = default)
 {
     using (var db = new GuoGuoCommunityContext())
     {
         if (string.IsNullOrWhiteSpace(dto.SmallDistrictId))
         {
             throw new NotImplementedException("小区Id信息不正确!");
         }
         return(await db.VipOwners.Where(x => x.IsDeleted == false && x.SmallDistrictId.ToString() == dto.SmallDistrictId).ToListAsync(token));
     }
 }
Ejemplo n.º 6
0
        public async Task <List <VipOwner> > GetAllAsync(VipOwnerDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                var list = await db.VipOwners.Include(x => x.SmallDistrict.Community.StreetOffice).Where(x => x.IsDeleted == false).ToListAsync(token);

                if (!string.IsNullOrWhiteSpace(dto.SmallDistrictId))
                {
                    list = list.Where(x => x.SmallDistrictId.ToString() == dto.SmallDistrictId).ToList();
                }
                if (!string.IsNullOrWhiteSpace(dto.Name))
                {
                    list = list.Where(x => x.Name.Contains(dto.Name) || x.RemarkName.Contains(dto.Name)).ToList();
                }
                //if (!string.IsNullOrWhiteSpace(dto.RemarkName))
                //{
                //    list = list.Where(x => x.RemarkName.Contains(dto.RemarkName)).ToList();
                //}
                return(list);
            }
        }
Ejemplo n.º 7
0
        public async Task DeleteAsync(VipOwnerDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.Id, out var uid))
                {
                    throw new NotImplementedException("业委会Id信息不正确!");
                }
                var vipOwners = await db.VipOwners.Where(x => x.Id == uid && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (vipOwners == null)
                {
                    throw new NotImplementedException("该业委会不存在!");
                }

                vipOwners.LastOperationTime   = dto.OperationTime;
                vipOwners.LastOperationUserId = dto.OperationUserId;
                vipOwners.DeletedTime         = dto.OperationTime;
                vipOwners.IsDeleted           = true;
                await db.SaveChangesAsync(token);
            }
        }
Ejemplo n.º 8
0
 public Task <List <VipOwner> > GetListIncludeAsync(VipOwnerDto dto, CancellationToken token = default)
 {
     throw new NotImplementedException();
 }