using SportCompetitionsContracts.BindingModels; using SportCompetitionsContracts.ViewModels; using SportCompetitionsDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SportCompetitionsDatabaseImplement.Models { public class Member : IMemberModel { public int Id { get; set; } [Required] public string? MemberFCs { get; set; } = string.Empty; [Required] public DateTime MemberBirthDate { get; set; } [Required] public string? MemberGender { get; set; } = string.Empty; [Required] public int TeamId { get; set; } public static Member? Create(MemberBindingModel model) { if (model == null) return null; return new Member() { Id = model.Id, MemberFCs = model.MemberFCs, MemberBirthDate = model.MemberBirthDate, MemberGender = model.MemberGender, TeamId = model.TeamId, }; } public void Update(MemberBindingModel model) { if (model == null) return; MemberFCs = model.MemberFCs; MemberBirthDate = model.MemberBirthDate; MemberGender = model.MemberGender; TeamId = model.TeamId; } public MemberViewModel GetViewModel => new() { Id = Id, MemberFCs = MemberFCs, MemberBirthDate = MemberBirthDate, MemberGender = MemberGender, TeamId = TeamId, }; } }