Skip to content

Commit 09ac486

Browse files
author
Chris Young
committed
Removed BaseDocument Properties
1 parent 541c2bf commit 09ac486

File tree

5 files changed

+9
-34
lines changed

5 files changed

+9
-34
lines changed

src/ArchitectNow.Mongo/ArchitectNow.Mongo.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
1919
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
2020
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
21-
</PropertyGroup>
21+
</PropertyGroup>
2222
<ItemGroup>
2323
<PackageReference Include="Autofac" Version="4.8.1" />
2424
<PackageReference Include="FluentValidation" Version="7.5.2" />
2525
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.0-rc1-final" />
2626
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.0-rc1-final" />
2727
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.0-rc1-final" />
28-
<PackageReference Include="MongoDB.Driver" Version="2.6.0" />
28+
<PackageReference Include="MongoDB.Driver" Version="2.6.0" />
2929
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
3030
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
3131
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0-rc1" />

src/ArchitectNow.Mongo/Db/BaseRepository.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,9 @@ public virtual async Task<bool> DeleteAllAsync()
8080
return true;
8181
}
8282

83-
public virtual Task<List<TModel>> GetAllAsync(bool onlyActive = true)
83+
public virtual Task<List<TModel>> GetAllAsync()
8484
{
85-
Task<List<TModel>> results;
86-
if (onlyActive)
87-
results = GetCollection().Find(x => x.IsActive).ToListAsync();
88-
else
89-
results = GetCollection().Find(model => true).ToListAsync();
85+
var results = GetCollection().Find(model => true).ToListAsync();
9086

9187
return results;
9288
}
@@ -102,11 +98,7 @@ public virtual async Task<TModel> SaveAsync(TModel item)
10298
{
10399
if (item.Id != Guid.Empty)
104100
item.UpdatedDate = DateTime.UtcNow;
105-
106-
if (item.OwnerUserId == null || item.OwnerUserId == Guid.Empty)
107-
if (CurrentContext != null && CurrentContext.CurrentUserId != Guid.Empty)
108-
item.OwnerUserId = CurrentContext.CurrentUserId;
109-
101+
110102
var errors = await ValidateObject(item);
111103

112104
if (errors.Any())
@@ -150,9 +142,9 @@ public virtual Task<bool> DeleteAsync(TModel item)
150142
/// <summary>
151143
/// Configures the indexes.
152144
/// </summary>
153-
public virtual async Task ConfigureIndexes()
145+
public virtual Task ConfigureIndexes()
154146
{
155-
await CreateIndex("Id", Builders<TModel>.IndexKeys.Ascending(x => x.Id).Ascending(x => x.IsActive));
147+
return Task.Run(() => { });
156148
}
157149

158150
/// <summary>

src/ArchitectNow.Mongo/Db/IBaseRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public interface IBaseRepository<T> : IBaseRepository
99
where T : BaseDocument
1010
{
1111
Task<bool> DeleteAllAsync();
12-
Task<List<T>> GetAllAsync(bool onlyActive = true);
12+
Task<List<T>> GetAllAsync();
1313
Task<T> GetOneAsync(Guid id);
1414
Task<T> SaveAsync(T item);
1515
Task<bool> DeleteAsync(Guid id);

src/ArchitectNow.Mongo/Db/RepositoryExtensions.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/ArchitectNow.Mongo/Models/BaseDocument.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public abstract class BaseDocument
1212
protected BaseDocument()
1313
{
1414
ValidationErrors = new List<ValidationResult>();
15-
IsActive = true;
1615
}
1716

1817
[BsonId(IdGenerator = typeof(CombGuidGenerator))]
@@ -27,10 +26,7 @@ protected BaseDocument()
2726
public DateTimeOffset? CreatedDate { get; set; } = DateTime.UtcNow;
2827

2928
public DateTimeOffset? UpdatedDate { get; set; } = DateTime.UtcNow;
30-
31-
public Guid? OwnerUserId { get; set; }
32-
public bool IsActive { get; set; }
33-
29+
3430
[JsonIgnore]
3531
[BsonIgnore]
3632
public List<ValidationResult> ValidationErrors { get; set; }

0 commit comments

Comments
 (0)