57 lines
1.3 KiB
C#
57 lines
1.3 KiB
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 Result : IResultModel
|
|
{
|
|
public int Id { get; set; }
|
|
[Required]
|
|
public string? ResultName { get; set; }
|
|
[Required]
|
|
public int CompetitionId { get; set; }
|
|
[Required]
|
|
public int TeamId { get; set; }
|
|
[Required]
|
|
public int ResultPosition { get; set; }
|
|
|
|
public static Result? Create(ResultBindingModel model)
|
|
{
|
|
if (model == null) return null;
|
|
return new Result()
|
|
{
|
|
Id = model.Id,
|
|
ResultName = model.ResultName,
|
|
CompetitionId = model.CompetitionId,
|
|
TeamId = model.TeamId,
|
|
ResultPosition = model.ResultPosition,
|
|
};
|
|
}
|
|
|
|
public void Update(ResultBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
ResultName = model.ResultName;
|
|
CompetitionId = model.CompetitionId;
|
|
TeamId = model.TeamId;
|
|
ResultPosition = model.ResultPosition;
|
|
}
|
|
|
|
public ResultViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
ResultName = ResultName,
|
|
CompetitionId = CompetitionId,
|
|
TeamId = TeamId,
|
|
ResultPosition = ResultPosition
|
|
};
|
|
}
|
|
}
|