SUBD_SchoolSchedule/SchoolSchedule/SchoolScheduleDataBaseImplement/Models/SchedulePlace.cs
2024-04-08 14:40:49 +04:00

41 lines
1002 B
C#

using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.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 SchoolScheduleDataBaseImplement.Models
{
public class SchedulePlace : ISchedulePlaceModel
{
public int Id { get; private set; }
[Required]
public TimeOnly Time { get; private set; }
[ForeignKey("SchedulePlaceId")]
public virtual List<Lesson> Lessons { get; set; } = new();
public static SchedulePlace Create(SchedulePlaceViewModel model)
{
return new SchedulePlace
{
Id = model.Id,
Time = model.Time,
};
}
public void Update(SchedulePlaceBindingModel model)
{
Time = model.Time;
}
public SchedulePlaceViewModel GetViewModel => new()
{
Id = Id,
Time = Time
};
}
}