Exemplo n.º 1
0
        public async Task <List <VipOwnerStructure> > GetAllAsync(VipOwnerStructureDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                var list = await db.VipOwnerStructures.Where(x => x.IsDeleted == false).ToListAsync(token);

                if (!string.IsNullOrWhiteSpace(dto.Name))
                {
                    list = list.Where(x => x.Name.Contains(dto.Name)).ToList();
                }
                if (!string.IsNullOrWhiteSpace(dto.Description))
                {
                    list = list.Where(x => x.Description.Contains(dto.Description)).ToList();
                }
                if (dto.IsReview.HasValue)
                {
                    list = list.Where(x => x.IsReview == dto.IsReview).ToList();
                }
                if (!string.IsNullOrWhiteSpace(dto.Weights))
                {
                    list = list.Where(x => x.Weights == dto.Weights).ToList();
                }
                return(list);
            }
        }
Exemplo n.º 2
0
        public async Task <VipOwnerStructure> AddAsync(VipOwnerStructureDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                var community = await db.VipOwnerStructures.Where(x => x.Name == dto.Name && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (community != null)
                {
                    throw new NotImplementedException("该业委会职能已存在!");
                }
                var entity = db.VipOwnerStructures.Add(new VipOwnerStructure
                {
                    Name                  = dto.Name,
                    Description           = dto.Description,
                    IsReview              = dto.IsReview.Value,
                    Weights               = dto.Weights,
                    CreateOperationTime   = dto.OperationTime,
                    CreateOperationUserId = dto.OperationUserId,
                    LastOperationTime     = dto.OperationTime,
                    LastOperationUserId   = dto.OperationUserId
                });
                await db.SaveChangesAsync(token);

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

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

                if (await db.VipOwnerStructures.Where(x => x.Name == dto.Name && x.IsDeleted == false && x.Id != uid).FirstOrDefaultAsync(token) != null)
                {
                    throw new NotImplementedException("该业委会职能已存在!");
                }
                vipOwnerStructure.Name                = dto.Name;
                vipOwnerStructure.Description         = dto.Description;
                vipOwnerStructure.Weights             = dto.Weights;
                vipOwnerStructure.IsReview            = dto.IsReview.Value;
                vipOwnerStructure.LastOperationTime   = dto.OperationTime;
                vipOwnerStructure.LastOperationUserId = dto.OperationUserId;
                await OnUpdateAsync(db, vipOwnerStructure, token);

                await db.SaveChangesAsync(token);
            }
        }
Exemplo n.º 4
0
        public async Task DeleteAsync(VipOwnerStructureDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.Id, out var uid))
                {
                    throw new NotImplementedException("业委会职能信息不正确!");
                }
                var vipOwnerStructures = await db.VipOwnerStructures.Where(x => x.Id == uid && x.IsDeleted == false).FirstOrDefaultAsync(token);

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


                vipOwnerStructures.LastOperationTime   = dto.OperationTime;
                vipOwnerStructures.LastOperationUserId = dto.OperationUserId;
                vipOwnerStructures.DeletedTime         = dto.OperationTime;
                vipOwnerStructures.IsDeleted           = true;
                await db.SaveChangesAsync(token);
            }
        }
Exemplo n.º 5
0
 public Task <List <VipOwnerStructure> > GetListAsync(VipOwnerStructureDto dto, CancellationToken token = default)
 {
     throw new NotImplementedException();
 }