using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;


namespace Sevomin.Models
{
    public class Parameter
    {
        [Key]
        public long Id { get; set; }
        
        [Required]
        public string Name { get; set; }

        [Required]
        public bool Moscow { get; set; }

        [Required]
        public byte DisplayMethod { get; set; }

        [StringLength(50)]
        public string DisplayFormat { get; set; }

        [Required]
        public string GroupName { get; set; }

        [StringLength(140)]
        public string CommentAvalin { get; set; }

        [StringLength(140)]
        public string CommentDovomin { get; set; }

        [StringLength(50)]
        public string ParameterValueId { get; set; }

        [NotMapped]
        public IQueryable<ParameterValue> ParameterValues
        {
            get
            {
                return SevominDbContext.Current.ParameterValues.Where(x => x.GroupKey == ParameterValueId);
            }
        }

        public virtual ICollection<JobParameter> JobParameters { get; set; }
        public virtual ICollection<DovominParameter> DovominParameters { get; set; }
    }
}
