2023-04-07 23:28:12 +04:00
|
|
|
|
using SchoolContracts.BindingModel;
|
|
|
|
|
using SchoolContracts.BindingModels;
|
|
|
|
|
using SchoolContracts.ViewModels;
|
|
|
|
|
using System;
|
2023-04-06 22:52:23 +04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.ConstrainedExecution;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SchoolDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class CircleLesson
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int CircleId { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int LessonId { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int Count { get; set; }
|
|
|
|
|
public virtual Lesson Lesson { get; set; } = new();
|
|
|
|
|
public virtual Circle Circle { get; set; } = new();
|
2023-04-07 23:28:12 +04:00
|
|
|
|
[ForeignKey("CircleLessonId")]
|
|
|
|
|
public virtual List<Payment> Payments { get; set; } = new();
|
|
|
|
|
public static CircleLesson Create(SchoolDatabase context, CircleLessonBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
return new CircleLesson()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Circle = context.Circles.First(x => x.Id == model.CircleId),
|
|
|
|
|
Lesson = context.Lessons.First(x => x.Id == model.LessonId)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(CircleLessonBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CircleLessonViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id
|
|
|
|
|
};
|
2023-04-06 22:52:23 +04:00
|
|
|
|
}
|
|
|
|
|
}
|