DD.WellWorkover.Cloud/AsbCloudApp/Extensions/ChangeLogExtensions.cs

33 lines
1014 B
C#

using AsbCloudApp.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsbCloudApp.Extensions
{
/// <summary>
/// Расширения для поиска в истории
/// </summary>
public static class ChangeLogExtensions
{
/// <summary>
/// Действительные на момент времени значения
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="items"></param>
/// <param name="moment"></param>
/// <returns></returns>
public static IEnumerable<T> WhereActualAtMoment<T>(this IEnumerable<T> items, DateTimeOffset moment)
where T : ChangeLogAbstract
{
var actualItems = items
.Where(item => item.Creation >= moment)
.Where(item => item.Obsolete is null || item.Obsolete <= moment);
return actualItems;
}
}
}