//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Fab2ApprovalSystem.Models
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations.Schema;
    using Fab2ApprovalSystem.DMO;

    public partial class Training
    {
        public int TrainingID { get; set; }
        public int ECN { get; set; }
        public Nullable<System.DateTime> StartedDate { get; set; }
        public Nullable<System.DateTime> CompletedDate { get; set; }
        public Nullable<bool> Status { get; set; }
        public Nullable<bool> Deleted { get; set; }
        public Nullable<System.DateTime> DeletedDate { get; set; }
        [NotMapped]
        public string Title
        {
            get
            {
                ECN_DMO ecnDMO = new ECN_DMO();
                string ECNTitle = ecnDMO.GetECN(ECN).Title;

                return ECNTitle;
            }
        }
        [NotMapped]
        public string ECNTrainingGroups
        {
            get
            {
                ECN_DMO ecnDMO = new ECN_DMO();
                TrainingDMO trainingDMO = new TrainingDMO();
                ECN ecn = ecnDMO.GetECN(ECN);
                List<int> trainingGroupIDs = trainingDMO.GetECNAssignedTrainingGroups(ECN);

                string groupNames = "";

                foreach (int groupId in trainingGroupIDs)
                {
                    string groupName = trainingDMO.GetTrainingGroupByID(groupId).TrainingGroupName;
                    groupNames += groupName + ",";
                }
                return groupNames;
            }
        }
    }
}