using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using ScaffoldingExample.Helpers;

namespace ScaffoldingExample.Models
{
    [MetadataType(typeof(ProcessorValidation))]
    public partial class Processor : IOrderHelper<Processor>
    {
        public int MinOrder(IEnumerable<Processor> data)
        {
            int Result = data.Min(x => x.Order).Value;
            return Result;
        }

        public int MaxOrder(IEnumerable<Processor> data)
        {
            int Result = data.Max(x => x.Order).Value;
            return Result;
        }

        public int GetOrder()
        {
            return this.Order.Value;
        }

        public void SetOrder(int newOrder)
        {
            this.Order = newOrder;
        }
    }

    public partial class ProcessorValidation
    {
        [Required]
        [Display(Name = "Наименование процессора")]
        public object ProcessorName { get; set; }
    }

    [MetadataType(typeof(ComputerValidation))]
    public partial class Computer
    {
    }

    public partial class ComputerValidation
    {
        [Required]
        [Display(Name = "Наименование компьютера")]
        public object ComputerName { get; set; }
        
        [Required]
        [Display(Name = "Емкость жесткого диска")]       
        public object HDD { get; set; }

        [Required]
        [DataType(DataType.Date, ErrorMessage = "Необходимо ввести дату")]
        [Display(Name = "Дата обновления")]       
        public object UpgradeDate { get; set; }
        
        [Required]
        [Display(Name = "Процессор")]       
        public object ProcessorId { get; set; }
    }

}