52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using UniversityContracts.BindingModels;
|
|
using UniversityContracts.ViewModels;
|
|
using UniversityModels.Models;
|
|
|
|
namespace UniversityDataBaseImplemet.Models
|
|
{
|
|
public class Stream : IStreamModel
|
|
{
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
[Required]
|
|
public int Course { get; set; }
|
|
[Required]
|
|
public int UserId { get; set; }
|
|
|
|
public int Id { get; private set; }
|
|
[ForeignKey("StreamId")]
|
|
public virtual List<EducationGroupStream> EducationGroupStream { get; set; } = new();
|
|
[ForeignKey("StreamId")]
|
|
public virtual List<StudentStream> StreamStudents { get; set; } = new();
|
|
public virtual User User { get; set; }
|
|
|
|
public static Stream Create(StreamBindingModel model)
|
|
{
|
|
return new Stream()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
Course = model.Course,
|
|
UserId = model.UserId
|
|
};
|
|
}
|
|
public void Update(StreamBindingModel model)
|
|
{
|
|
Name = model.Name;
|
|
Course = model.Course;
|
|
UserId = model.UserId;
|
|
}
|
|
public StreamViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
UserId = UserId,
|
|
Course= Course
|
|
};
|
|
}
|
|
}
|