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

33 lines
975 B
C#
Raw Normal View History

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