using GreenTree.Strohrmann.ERP.Core.Domain.Business;
using GreenTree.Strohrmann.ERP.Web.Models.Shared;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace GreenTree.Strohrmann.ERP.Web.Models.Business
{
    public class CraftEmployeeModel
    {
        #region Properties

        /// <summary>
        /// Craft employee model index
        /// </summary>
        public int? Index { get; set; }

        /// <summary>
        /// Craft employee Dictionary identifier
        /// </summary>
        public string DictIdentifier { get; set; }

        /// <summary>
        /// Craft employee id
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// Craft id
        /// </summary>
        [Display(Name = "ID")]
        public int CraftId { get; set; }

        /// <summary>
        /// Craft
        /// </summary>
        [Display(Name = "Gewerk")]
        public virtual CraftModel Craft { get; set; }

        /// <summary>
        /// Employee id
        /// </summary>
        [Display(Name = "Mitarbeiter")]
        public int EmployeeId { get; set; }

        /// <summary>
        /// Employee
        /// </summary>
        [Display(Name = "Mitarbeiter")]
        public virtual EmployeeModel Employee { get; set; }

        /// <summary>
        /// The amount of employee working hours
        /// </summary>
        [Display(Name = "Menge / Dauer")]
        public decimal Amount { get; set; }

        /// <summary>
        /// The value of the employee working hours
        /// </summary>
        [Display(Name = "Wert")]
        [DisplayFormat(ApplyFormatInEditMode = false, DataFormatString = "{0:C}")]
        public float Value { get; set; }

        /// <summary>
        /// Craft employee comment
        /// </summary>
        [Display(Name = "Kommentar")]
        public string Comment { get; set; }

        #endregion

        #region Ctor

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

        /// <summary>
        /// Initializes a new instance of the CraftEmployeeModel class
        /// </summary>
        /// <param name="craftEmployee">The base craft employee.</param>
        public CraftEmployeeModel(CraftEmployee craftEmployee)
        {
            if (craftEmployee == null) return;

            Id = craftEmployee.Id;
            CraftId = craftEmployee.CraftId;
            EmployeeId = craftEmployee.EmployeeId;
            Amount = craftEmployee.Amount;
            Value = Convert.ToSingle(craftEmployee.Value);
            Comment = craftEmployee.Comment;
        }

        #endregion
    }
}
