47 lines
1021 B
C#
47 lines
1021 B
C#
|
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 Team : ITeamModel
|
|||
|
{
|
|||
|
public int Id { get; set; }
|
|||
|
[Required]
|
|||
|
public string? TeamName { get; set; }
|
|||
|
[Required]
|
|||
|
public string? TeamCountry { get; set; }
|
|||
|
|
|||
|
public static Team? Create(TeamBindingModel model)
|
|||
|
{
|
|||
|
if (model == null) return null;
|
|||
|
return new Team()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
TeamName = model.TeamName,
|
|||
|
TeamCountry = model.TeamCountry,
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(TeamBindingModel model)
|
|||
|
{
|
|||
|
if (model == null) return;
|
|||
|
TeamName = model.TeamName;
|
|||
|
TeamCountry = model.TeamCountry;
|
|||
|
}
|
|||
|
|
|||
|
public TeamViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
TeamName = TeamName,
|
|||
|
TeamCountry = TeamCountry
|
|||
|
};
|
|||
|
}
|
|||
|
}
|