using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
using UniversityModels.Models;

namespace UniversityDataBaseImplemet.Models
{
    public class EducationStatus : IEducationStatusModel
    {
        public int Id { get; private set; }
        [Required]
        public string Name { get; set; } = string.Empty;
        [Required]
        public int UserId { get; set; }
        [ForeignKey("EducationStatusId")]
        public virtual List<Student> Students { get; set; } = new();
        public virtual User User { get; set; }

        public static EducationStatus? Create(EducationStatusBindingModel model)
        {
            return new EducationStatus()
            {
                Id = model.Id,
                Name = model.Name,
                UserId = model.UserId,
            };
        }
        public void Update(EducationStatusBindingModel model)
        {
            if (model == null)
            {
                return;
            }
            Name = model.Name;
            UserId = model.UserId;
        }
        public EducationStatusViewModel GetViewModel => new()
        {
            Id = Id,
            Name = Name,
            UserId = UserId,
        };
    }
}
