2023-04-03 20:19:36 +04:00
|
|
|
|
using SchoolAgainStudyContracts.BindingModel;
|
|
|
|
|
using SchoolAgainStudyContracts.ViewModel;
|
|
|
|
|
using SchoolAgainStudyDataModels.Models;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace SchoolAgainStudyDataBaseImplements.Models
|
|
|
|
|
{
|
|
|
|
|
public class Material : IMaterial
|
|
|
|
|
{
|
|
|
|
|
[Required]
|
|
|
|
|
public string Title { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string SphereUse { get; set; } = string.Empty;
|
2023-04-05 21:11:51 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int TeacherId { get; set; }
|
|
|
|
|
public virtual Teacher Teacher { get; set; }
|
2023-04-03 20:19:36 +04:00
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[ForeignKey("MaterialId")]
|
|
|
|
|
public virtual List<LessonMaterial> LessonMaterials { get; set; } = new();
|
|
|
|
|
[ForeignKey("MaterialId")]
|
|
|
|
|
public virtual List<TaskMaterial> TaskMaterial { get; set; } = new();
|
2023-04-05 21:11:51 +04:00
|
|
|
|
|
2023-04-03 20:19:36 +04:00
|
|
|
|
|
|
|
|
|
public static Material? Create(MaterialBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Material()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Title = model.Title,
|
2023-04-05 21:11:51 +04:00
|
|
|
|
SphereUse = model.SphereUse,
|
|
|
|
|
TeacherId = model.TeacherId,
|
2023-04-03 20:19:36 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Material Create(MaterialViewModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Material
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Title = model.Title,
|
2023-04-05 21:11:51 +04:00
|
|
|
|
SphereUse = model.SphereUse,
|
|
|
|
|
TeacherId=model.TeacherId
|
2023-04-03 20:19:36 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(MaterialBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Title = model.Title;
|
|
|
|
|
SphereUse = model.SphereUse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MaterialViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Title = Title,
|
2023-04-05 21:11:51 +04:00
|
|
|
|
SphereUse = SphereUse,
|
|
|
|
|
TeacherId = TeacherId,
|
2023-04-03 20:19:36 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|