56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UniversityContracts.BindingModels;
|
|
using UniversityContracts.ViewModels;
|
|
using UniversityModels.Models;
|
|
|
|
namespace UniversityDataBaseImplemet.Models
|
|
{
|
|
public class Document : IDocumentModel
|
|
{
|
|
public int Id { get; private set; }
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
[Required]
|
|
public DateTime Date { get; set; }
|
|
[Required]
|
|
public int UserId { get; set; }
|
|
[ForeignKey("DocumentId")]
|
|
public virtual List<StudentDocument> Students { get; set; } = new();
|
|
public virtual EducationStatus User { get; set; }
|
|
|
|
public static Document? Create(DocumentBindingModel model)
|
|
{
|
|
return new Document()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
Date = model.Date,
|
|
UserId = model.UserId,
|
|
};
|
|
}
|
|
public void Update(DocumentBindingModel model)
|
|
{
|
|
if(model == null)
|
|
{
|
|
return;
|
|
}
|
|
Name = model.Name;
|
|
Date = model.Date;
|
|
UserId = model.UserId;
|
|
}
|
|
public DocumentViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
Date = Date,
|
|
UserId = UserId,
|
|
};
|
|
}
|
|
}
|