72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
|
using SchoolAgainStudyContracts.BindingModel;
|
|||
|
using SchoolAgainStudyContracts.ViewModel;
|
|||
|
using SchoolAgainStudyDataModels.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace SchoolAgainStudyDataBaseImplements.Models
|
|||
|
{
|
|||
|
public class Interest : IInterest
|
|||
|
{
|
|||
|
[Required]
|
|||
|
public string Title { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public string Description { get; set; } = string.Empty;
|
|||
|
|
|||
|
public int Id { get; set; }
|
|||
|
[ForeignKey("InterestId")]
|
|||
|
public virtual List<StudentInterest> StudentInterests { get; set; } = new();
|
|||
|
[ForeignKey("InterestId")]
|
|||
|
public virtual List<DiyInterest> DiyInterests { get; set; } = new();
|
|||
|
[ForeignKey("InterestId")]
|
|||
|
public virtual List<ProductInterest> ProductInterests { get; set; } = new();
|
|||
|
|
|||
|
public static Interest? Create(InterestBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Interest()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
Title = model.Title,
|
|||
|
Description = model.Description
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public static Interest Create(InterestViewModel model)
|
|||
|
{
|
|||
|
return new Interest
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
Title = model.Title,
|
|||
|
Description = model.Description
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(InterestBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
Title = model.Title;
|
|||
|
Description = model.Description;
|
|||
|
}
|
|||
|
|
|||
|
public InterestViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
Title = Title,
|
|||
|
Description = Description
|
|||
|
};
|
|||
|
}
|
|||
|
}
|