Skip to content

Commit

Permalink
Chore: FilterByRange method names altered to be more clear.
Browse files Browse the repository at this point in the history
  • Loading branch information
LibardiFelipe committed Dec 28, 2022
1 parent 7510e52 commit 71ddf83
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions TemplateBase.Application/Queries/Base/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public Query(string id)
_id = guidId;
}

public TQuery FilterByRangeCreation(DateTime? startDate, DateTime? endDate)
public TQuery FilterByCreationRange(DateTime? startDate, DateTime? endDate)
{
_createdAtStart = startDate;
_createdAtEnd = endDate;
return (TQuery)this;
}

public TQuery FilterByRangeUpdate(DateTime? startDate, DateTime? endDate)
public TQuery FilterByUpdateRange(DateTime? startDate, DateTime? endDate)
{
_updatedAtStart = startDate;
_updatedAtEnd = endDate;
Expand Down
4 changes: 2 additions & 2 deletions TemplateBase.Application/Queries/Users/UserQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public override ISpecification<User> ToSpecification()
spec.FilterById(_id.Value);

if (_createdAtStart.HasValue && _createdAtEnd.HasValue)
spec.FilterByRangeCreation(_createdAtStart.Value, _createdAtEnd.Value);
spec.FilterByCreationRange(_createdAtStart.Value, _createdAtEnd.Value);

if (_updatedAtStart.HasValue && _updatedAtEnd.HasValue)
spec.FilterByRangeUpdate(_updatedAtStart.Value, _updatedAtEnd.Value);
spec.FilterByUpdateRange(_updatedAtStart.Value, _updatedAtEnd.Value);

if (!string.IsNullOrWhiteSpace(_name))
spec.FilterByName(_name);
Expand Down
6 changes: 3 additions & 3 deletions TemplateBase.Domain/Specifications/Base/BaseSpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public virtual TImplementation FilterById(Guid id)
return (TImplementation)this;
}

public virtual TImplementation FilterByRangeCreation(DateTime start, DateTime end)
public virtual TImplementation FilterByCreationRange(DateTime start, DateTime end)
{
CriteriaAnd((T x) => x.CreatedAt.Date >= start.Date && x.CreatedAt.Date <= end.Date);
return (TImplementation)this;
}

public virtual TImplementation FilterByRangeUpdate(DateTime start, DateTime end)
public virtual TImplementation FilterByUpdateRange(DateTime start, DateTime end)
{
CriteriaAnd((T x) => x.UpdatedAt.HasValue ? (x.UpdatedAt.Value.Date >= start.Date && x.UpdatedAt.Value.Date <= end) : false);
CriteriaAnd((T x) => x.UpdatedAt.HasValue && (x.UpdatedAt.Value.Date >= start.Date && x.UpdatedAt.Value.Date <= end));
return (TImplementation)this;
}

Expand Down
4 changes: 2 additions & 2 deletions TemplateBase.WebAPI/AutoMapper/RequestsToQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public RequestsToQueries()
.FilterByName(src.Name)
.FilterByEmail(src.Email)
.FilterByType(src.Type)
.FilterByRangeCreation(src.CreatedAtStart, src.CreatedAtEnd)
.FilterByRangeUpdate(src.UpdatedAtStart, src.UpdatedAtEnd);
.FilterByCreationRange(src.CreatedAtStart, src.CreatedAtEnd)
.FilterByUpdateRange(src.UpdatedAtStart, src.UpdatedAtEnd);
})
.IgnoreAllPropertiesWithAnInaccessibleSetter()
.AfterMap((_, src) => src.Validate());
Expand Down

0 comments on commit 71ddf83

Please sign in to comment.