aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.BL/ExtensionMethods/ObservableEntityExtensions.cs
blob: 9178c8300aa1f5a24df911446a6fc097cce31ea3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL;
using Tango.BL.Entities;

/// <summary>
/// Contains <see cref="ObservableEntityBase"/> extension methods.
/// </summary>
public static class ObservableEntityExtensions
{
    /// <summary>
    /// Performs a shallow cloning of this entity.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="entity">The entity.</param>
    /// <returns></returns>
    public static T CloneEntity<T>(this T entity) where T : class, IObservableEntity
    {
        T cloned = entity.ShallowClone();
        cloned.ID = 0;
        cloned.Guid = Guid.NewGuid().ToString();
        cloned.LastUpdated = DateTime.UtcNow;
        return cloned;
    }
}