using GreenTree.Maschinenbestellungen.Core.Domain.Shared;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace GreenTree.Maschinenbestellungen.Web.Models.Shared
{
    public class TrackingModel
    {
        #region Properties

        /// <summary>
        /// Tracked creation user
        /// </summary>
        [Display(Name = "Erstellt von")]
        public string CreatedBy { get; set; }

        /// <summary>
        /// Tracked creation datetime
        /// </summary>
        [Display(Name = "Erstellt am")]
        [DisplayFormat(DataFormatString = "{0:dd.MM.yyyy - HH:mm \"Uhr\"}")]
        public DateTime CreatedOn { get; set; }

        /// <summary>
        /// Tracked changed user
        /// </summary>
        [Display(Name = "Geändert von")]
        public string ChangedBy { get; set; }

        /// <summary>
        /// Tracked changed datetime
        /// </summary>
        [Display(Name = "Geändert am")]
        [DisplayFormat(DataFormatString = "{0:dd.MM.yyyy - HH:mm \"Uhr\"}")]
        public DateTime? ChangedOn { get; set; }

        #endregion

        #region Ctor

        /// <summary>
        /// Initializes a new instance of the TrackModel class
        /// </summary>
        public TrackingModel() { }

        /// <summary>
        /// Initializes a new instance of the TrackModel class
        /// </summary>
        /// <param name="trackedEntity">The based tracked entity.</param>
        public TrackingModel(TrackedEntity trackedEntity)
        {
            if (trackedEntity == null) return;

            CreatedBy = trackedEntity.CreatedBy;
            CreatedOn = trackedEntity.CreatedOn;
            ChangedBy = trackedEntity.ChangedBy;
            ChangedOn = trackedEntity.ChangedOn;
        }

        #endregion
    }
}
