52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using MongoDB.Bson.Serialization.Attributes;
|
|
using SportCompetitionsContracts.BindingModels;
|
|
using SportCompetitionsContracts.ViewModels;
|
|
using SportCompetitionsDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SportCompetitionsMongo.Models
|
|
{
|
|
public class Team : ITeamModel
|
|
{
|
|
[BsonId]
|
|
[BsonElement("_id")]
|
|
public int Id { get; set; }
|
|
|
|
[BsonRequired]
|
|
public string TeamName { get; set; } = string.Empty;
|
|
|
|
[BsonRequired]
|
|
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;
|
|
Id = model.Id;
|
|
TeamName = model.TeamName;
|
|
TeamCountry = model.TeamCountry;
|
|
}
|
|
|
|
public TeamViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
TeamName = TeamName,
|
|
TeamCountry = TeamCountry,
|
|
};
|
|
}
|
|
}
|