вроде работает
This commit is contained in:
parent
dc65d00769
commit
b42449a96c
49
SportCompetitions/SportCompetitions.sln
Normal file
49
SportCompetitions/SportCompetitions.sln
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.3.32825.248
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SportCompetitionsBusinessLogic", "SportCompetitionsBusinessLogic\SportCompetitionsBusinessLogic.csproj", "{FFB7B35D-30CA-46AB-86E9-6BE64CC49E07}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SportCompetitionsContracts", "SportCompetitionsContracts\SportCompetitionsContracts.csproj", "{AEB7A4E0-5078-45DA-8E5D-6B07C176EA69}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SportCompetitionsDataModels", "SportCompetitionsDataModels\SportCompetitionsDataModels.csproj", "{43BB3C79-C5E4-487C-BFBB-A35A6E87951B}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SportCompetitionsDatabaseImplement", "SportCompetitionsDatabaseImplement\SportCompetitionsDatabaseImplement.csproj", "{09B7CD5C-0160-4ACD-951B-D740A036A26D}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SportCompetitionsView", "SportCompetitionsView\SportCompetitionsView.csproj", "{5D947E6B-6987-4A08-90FC-3B554CE676E3}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{FFB7B35D-30CA-46AB-86E9-6BE64CC49E07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FFB7B35D-30CA-46AB-86E9-6BE64CC49E07}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FFB7B35D-30CA-46AB-86E9-6BE64CC49E07}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FFB7B35D-30CA-46AB-86E9-6BE64CC49E07}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AEB7A4E0-5078-45DA-8E5D-6B07C176EA69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AEB7A4E0-5078-45DA-8E5D-6B07C176EA69}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AEB7A4E0-5078-45DA-8E5D-6B07C176EA69}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AEB7A4E0-5078-45DA-8E5D-6B07C176EA69}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{43BB3C79-C5E4-487C-BFBB-A35A6E87951B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{43BB3C79-C5E4-487C-BFBB-A35A6E87951B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{43BB3C79-C5E4-487C-BFBB-A35A6E87951B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{43BB3C79-C5E4-487C-BFBB-A35A6E87951B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{09B7CD5C-0160-4ACD-951B-D740A036A26D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{09B7CD5C-0160-4ACD-951B-D740A036A26D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{09B7CD5C-0160-4ACD-951B-D740A036A26D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{09B7CD5C-0160-4ACD-951B-D740A036A26D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5D947E6B-6987-4A08-90FC-3B554CE676E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5D947E6B-6987-4A08-90FC-3B554CE676E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5D947E6B-6987-4A08-90FC-3B554CE676E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5D947E6B-6987-4A08-90FC-3B554CE676E3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {12AF8F8B-CB1C-49C6-ACB2-E7AD7E4A12CE}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -0,0 +1,93 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class CoachLogic : ICoachLogic
|
||||||
|
{
|
||||||
|
private readonly ICoachStorage _coachStorage;
|
||||||
|
|
||||||
|
public CoachLogic(ICoachStorage coachStorage)
|
||||||
|
{
|
||||||
|
_coachStorage = coachStorage;
|
||||||
|
}
|
||||||
|
public CoachViewModel? ReadElement(CoachSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _coachStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CoachViewModel>? ReadList(CoachSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _coachStorage.GetFullList() : _coachStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(CoachBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_coachStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(CoachBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_coachStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(CoachBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_coachStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(CoachBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.CoachName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет ФИО", nameof(model.CoachName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class CompetitionLogic : ICompetitionLogic
|
||||||
|
{
|
||||||
|
private readonly ICompetitionStorage _competitionStorage;
|
||||||
|
|
||||||
|
public CompetitionLogic(ICompetitionStorage competitionStorage)
|
||||||
|
{
|
||||||
|
_competitionStorage = competitionStorage;
|
||||||
|
}
|
||||||
|
public CompetitionViewModel? ReadElement(CompetitionSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _competitionStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CompetitionViewModel>? ReadList(CompetitionSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _competitionStorage.GetFullList() : _competitionStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(CompetitionBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_competitionStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(CompetitionBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_competitionStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(CompetitionBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_competitionStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(CompetitionBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.CompetitionName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия", nameof(model.CompetitionName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ParticipantLogic : IParticipantLogic
|
||||||
|
{
|
||||||
|
private readonly IParticipantStorage _participantStorage;
|
||||||
|
|
||||||
|
public ParticipantLogic(IParticipantStorage participantStorage)
|
||||||
|
{
|
||||||
|
_participantStorage = participantStorage;
|
||||||
|
}
|
||||||
|
public ParticipantViewModel? ReadElement(ParticipantSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _participantStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ParticipantViewModel>? ReadList(ParticipantSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _participantStorage.GetFullList() : _participantStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ParticipantBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_participantStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ParticipantBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_participantStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ParticipantBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_participantStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ParticipantBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ParticipantName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет ФИО", nameof(model.ParticipantName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class SportClubLogic : ISportClubLogic
|
||||||
|
{
|
||||||
|
private readonly ISportClubStorage _sportClubStorage;
|
||||||
|
|
||||||
|
public SportClubLogic(ISportClubStorage sportClubStorage)
|
||||||
|
{
|
||||||
|
_sportClubStorage = sportClubStorage;
|
||||||
|
}
|
||||||
|
public SportClubViewModel? ReadElement(SportClubSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _sportClubStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SportClubViewModel>? ReadList(SportClubSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _sportClubStorage.GetFullList() : _sportClubStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(SportClubBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_sportClubStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(SportClubBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_sportClubStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(SportClubBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_sportClubStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(SportClubBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.SportClubName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия", nameof(model.SportClubName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class SportTypeLogic : ISportTypeLogic
|
||||||
|
{
|
||||||
|
private readonly ISportTypeStorage _sportTypeStorage;
|
||||||
|
|
||||||
|
public SportTypeLogic(ISportTypeStorage sportTypeStorage)
|
||||||
|
{
|
||||||
|
_sportTypeStorage = sportTypeStorage;
|
||||||
|
}
|
||||||
|
public SportTypeViewModel? ReadElement(SportTypeSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _sportTypeStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SportTypeViewModel>? ReadList(SportTypeSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _sportTypeStorage.GetFullList() : _sportTypeStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(SportTypeBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_sportTypeStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(SportTypeBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_sportTypeStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(SportTypeBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_sportTypeStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(SportTypeBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.SportTypeName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия", nameof(model.SportTypeName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SportCompetitionsContracts\SportCompetitionsContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\SportCompetitionsDataModels\SportCompetitionsDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,19 @@
|
|||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class CoachBindingModel : ICoachModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? CoachName { get; set; }
|
||||||
|
public int BirthYear { get; set; }
|
||||||
|
public string? Country { get; set; }
|
||||||
|
public int SportClubId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class CompetitionBindingModel : ICompetitionModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? CompetitionName { get; set; }
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
public DateTime EndDate { get; set; }
|
||||||
|
public string? Location { get; set; }
|
||||||
|
public int SportTypeId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ParticipantBindingModel : IParticipantModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? ParticipantName { get; set; }
|
||||||
|
public int BirthYear { get; set; }
|
||||||
|
public string? Country { get; set; }
|
||||||
|
public string? Gender { get; set; }
|
||||||
|
public int CoachId { get; set; }
|
||||||
|
public int CompetitionId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class SportClubBindingModel : ISportClubModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? SportClubName { get; set; }
|
||||||
|
public string? SportClubAddress { get; set; }
|
||||||
|
public string? SportClubPhone { get; set; }
|
||||||
|
public string? SportClubEmail { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class SportTypeBindingModel : ISportTypeModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? SportTypeName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface ICoachLogic
|
||||||
|
{
|
||||||
|
List<CoachViewModel>? ReadList(CoachSearchModel? model);
|
||||||
|
CoachViewModel? ReadElement(CoachSearchModel model);
|
||||||
|
|
||||||
|
bool Create(CoachBindingModel model);
|
||||||
|
bool Update(CoachBindingModel model);
|
||||||
|
bool Delete(CoachBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface ICompetitionLogic
|
||||||
|
{
|
||||||
|
List<CompetitionViewModel>? ReadList(CompetitionSearchModel? model);
|
||||||
|
CompetitionViewModel? ReadElement(CompetitionSearchModel model);
|
||||||
|
|
||||||
|
bool Create(CompetitionBindingModel model);
|
||||||
|
bool Update(CompetitionBindingModel model);
|
||||||
|
bool Delete(CompetitionBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IParticipantLogic
|
||||||
|
{
|
||||||
|
List<ParticipantViewModel>? ReadList(ParticipantSearchModel? model);
|
||||||
|
ParticipantViewModel? ReadElement(ParticipantSearchModel model);
|
||||||
|
|
||||||
|
bool Create(ParticipantBindingModel model);
|
||||||
|
bool Update(ParticipantBindingModel model);
|
||||||
|
bool Delete(ParticipantBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface ISportClubLogic
|
||||||
|
{
|
||||||
|
List<SportClubViewModel>? ReadList(SportClubSearchModel? model);
|
||||||
|
SportClubViewModel? ReadElement(SportClubSearchModel model);
|
||||||
|
|
||||||
|
bool Create(SportClubBindingModel model);
|
||||||
|
bool Update(SportClubBindingModel model);
|
||||||
|
bool Delete(SportClubBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface ISportTypeLogic
|
||||||
|
{
|
||||||
|
List<SportTypeViewModel>? ReadList(SportTypeSearchModel? model);
|
||||||
|
SportTypeViewModel? ReadElement(SportTypeSearchModel model);
|
||||||
|
|
||||||
|
bool Create(SportTypeBindingModel model);
|
||||||
|
bool Update(SportTypeBindingModel model);
|
||||||
|
bool Delete(SportTypeBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class CoachSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? CoachName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class CompetitionSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? CompetitionName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ParticipantSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? ParticipantName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class SportClubSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? SportClubName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class SportTypeSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? SportTypeName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SportCompetitionsDataModels\SportCompetitionsDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,22 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface ICoachStorage
|
||||||
|
{
|
||||||
|
List<CoachViewModel> GetFullList();
|
||||||
|
List<CoachViewModel> GetFilteredList(CoachSearchModel model);
|
||||||
|
|
||||||
|
CoachViewModel? GetElement(CoachSearchModel model);
|
||||||
|
CoachViewModel? Insert(CoachBindingModel model);
|
||||||
|
CoachViewModel? Update(CoachBindingModel model);
|
||||||
|
CoachViewModel? Delete(CoachBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface ICompetitionStorage
|
||||||
|
{
|
||||||
|
List<CompetitionViewModel> GetFullList();
|
||||||
|
List<CompetitionViewModel> GetFilteredList(CompetitionSearchModel model);
|
||||||
|
|
||||||
|
CompetitionViewModel? GetElement(CompetitionSearchModel model);
|
||||||
|
CompetitionViewModel? Insert(CompetitionBindingModel model);
|
||||||
|
CompetitionViewModel? Update(CompetitionBindingModel model);
|
||||||
|
CompetitionViewModel? Delete(CompetitionBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IParticipantStorage
|
||||||
|
{
|
||||||
|
List<ParticipantViewModel> GetFullList();
|
||||||
|
List<ParticipantViewModel> GetFilteredList(ParticipantSearchModel model);
|
||||||
|
|
||||||
|
ParticipantViewModel? GetElement(ParticipantSearchModel model);
|
||||||
|
ParticipantViewModel? Insert(ParticipantBindingModel model);
|
||||||
|
ParticipantViewModel? Update(ParticipantBindingModel model);
|
||||||
|
ParticipantViewModel? Delete(ParticipantBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface ISportClubStorage
|
||||||
|
{
|
||||||
|
List<SportClubViewModel> GetFullList();
|
||||||
|
List<SportClubViewModel> GetFilteredList(SportClubSearchModel model);
|
||||||
|
|
||||||
|
SportClubViewModel? GetElement(SportClubSearchModel model);
|
||||||
|
SportClubViewModel? Insert(SportClubBindingModel model);
|
||||||
|
SportClubViewModel? Update(SportClubBindingModel model);
|
||||||
|
SportClubViewModel? Delete(SportClubBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface ISportTypeStorage
|
||||||
|
{
|
||||||
|
List<SportTypeViewModel> GetFullList();
|
||||||
|
List<SportTypeViewModel> GetFilteredList(SportTypeSearchModel model);
|
||||||
|
|
||||||
|
SportTypeViewModel? GetElement(SportTypeSearchModel model);
|
||||||
|
SportTypeViewModel? Insert(SportTypeBindingModel model);
|
||||||
|
SportTypeViewModel? Update(SportTypeBindingModel model);
|
||||||
|
SportTypeViewModel? Delete(SportTypeBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class CoachViewModel : ICoachModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("ФИО тренера")]
|
||||||
|
public string? CoachName { get; set; }
|
||||||
|
[DisplayName("Год рождения")]
|
||||||
|
public int BirthYear { get; set; }
|
||||||
|
[DisplayName("Страна")]
|
||||||
|
public string? Country { get; set; }
|
||||||
|
public int SportClubId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class CompetitionViewModel : ICompetitionModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название соревнования")]
|
||||||
|
public string? CompetitionName { get; set; }
|
||||||
|
[DisplayName("Начало соревнований")]
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
[DisplayName("Конец соревнований")]
|
||||||
|
public DateTime EndDate { get; set; }
|
||||||
|
[DisplayName("Локация")]
|
||||||
|
public string? Location { get; set; }
|
||||||
|
public int SportTypeId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ParticipantViewModel : IParticipantModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("ФИО участника")]
|
||||||
|
public string? ParticipantName { get; set; }
|
||||||
|
[DisplayName("Год рождения")]
|
||||||
|
public int BirthYear { get; set; }
|
||||||
|
[DisplayName("Страна")]
|
||||||
|
public string? Country { get; set; }
|
||||||
|
[DisplayName("Пол")]
|
||||||
|
public string? Gender { get; set; }
|
||||||
|
public int CoachId { get; set; }
|
||||||
|
public int CompetitionId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class SportClubViewModel : ISportClubModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название спортивного клуба")]
|
||||||
|
public string? SportClubName { get; set; }
|
||||||
|
[DisplayName("Адрес спортивного клуба")]
|
||||||
|
public string? SportClubAddress { get; set; }
|
||||||
|
[DisplayName("Телефон спортивного клуба")]
|
||||||
|
public string? SportClubPhone { get; set; }
|
||||||
|
[DisplayName("Почта спортивного клуба")]
|
||||||
|
public string? SportClubEmail { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
|
||||||
|
namespace SportCompetitionsContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class SportTypeViewModel : ISportTypeModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название вида спорта")]
|
||||||
|
public string? SportTypeName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
SportCompetitions/SportCompetitionsDataModels/IId.cs
Normal file
13
SportCompetitions/SportCompetitionsDataModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDataModels
|
||||||
|
{
|
||||||
|
public interface IId
|
||||||
|
{
|
||||||
|
int Id { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ICoachModel : IId
|
||||||
|
{
|
||||||
|
string CoachName { get; set; }
|
||||||
|
int BirthYear { get; set; }
|
||||||
|
string Country { get; set; }
|
||||||
|
int SportClubId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ICompetitionModel : IId
|
||||||
|
{
|
||||||
|
string CompetitionName { get; set; }
|
||||||
|
DateTime StartDate { get; }
|
||||||
|
DateTime EndDate { get; }
|
||||||
|
string Location { get; set; }
|
||||||
|
int SportTypeId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IParticipantModel : IId
|
||||||
|
{
|
||||||
|
string ParticipantName { get; set; }
|
||||||
|
int BirthYear { get; set; }
|
||||||
|
string Country { get; set; }
|
||||||
|
string Gender { get; set; }
|
||||||
|
int CoachId { get; set; }
|
||||||
|
int CompetitionId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ISportClubModel : IId
|
||||||
|
{
|
||||||
|
string SportClubName { get; set; }
|
||||||
|
string SportClubAddress { get; set; }
|
||||||
|
string SportClubPhone { get; set; }
|
||||||
|
string? SportClubEmail { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ISportTypeModel : IId
|
||||||
|
{
|
||||||
|
string SportTypeName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,77 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class CoachStorage : ICoachStorage
|
||||||
|
{
|
||||||
|
public List<CoachViewModel> GetFilteredList(CoachSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.CoachName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.Coaches.Where(x => x.CoachName.Contains(model.CoachName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CoachViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.Coaches.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoachViewModel? Delete(CoachBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var element = context.Coaches.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Coaches.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoachViewModel? GetElement(CoachSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.Coaches.FirstOrDefault(x => (!string.IsNullOrEmpty(model.CoachName)) && x.CoachName == model.CoachName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoachViewModel? Insert(CoachBindingModel model)
|
||||||
|
{
|
||||||
|
var newCoach = Coach.Create(model);
|
||||||
|
if (newCoach == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
context.Coaches.Add(newCoach);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newCoach.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoachViewModel? Update(CoachBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var component = context.Coaches.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class CompetitionStorage : ICompetitionStorage
|
||||||
|
{
|
||||||
|
public List<CompetitionViewModel> GetFilteredList(CompetitionSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.CompetitionName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.Competitions.Where(x => x.CompetitionName.Contains(model.CompetitionName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CompetitionViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.Competitions.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompetitionViewModel? Delete(CompetitionBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var element = context.Competitions.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Competitions.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompetitionViewModel? GetElement(CompetitionSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.Competitions.FirstOrDefault(x => (!string.IsNullOrEmpty(model.CompetitionName)) && x.CompetitionName == model.CompetitionName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompetitionViewModel? Insert(CompetitionBindingModel model)
|
||||||
|
{
|
||||||
|
var newCompetition = Competition.Create(model);
|
||||||
|
if (newCompetition == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
context.Competitions.Add(newCompetition);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newCompetition.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompetitionViewModel? Update(CompetitionBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var component = context.Competitions.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Metrics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ParticipantStorage : IParticipantStorage
|
||||||
|
{
|
||||||
|
public List<ParticipantViewModel> GetFilteredList(ParticipantSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ParticipantName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.Participants.Where(x => x.ParticipantName.Contains(model.ParticipantName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ParticipantViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.Participants.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticipantViewModel? Delete(ParticipantBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var element = context.Participants.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Participants.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticipantViewModel? GetElement(ParticipantSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.Participants.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ParticipantName)) && x.ParticipantName == model.ParticipantName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticipantViewModel? Insert(ParticipantBindingModel model)
|
||||||
|
{
|
||||||
|
var newParticipant = Participant.Create(model);
|
||||||
|
if (newParticipant == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
context.Participants.Add(newParticipant);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newParticipant.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticipantViewModel? Update(ParticipantBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var component = context.Participants.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class SportClubStorage : ISportClubStorage
|
||||||
|
{
|
||||||
|
public List<SportClubViewModel> GetFilteredList(SportClubSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.SportClubName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.SportClubs.Where(x => x.SportClubName.Contains(model.SportClubName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SportClubViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.SportClubs.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportClubViewModel? Delete(SportClubBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var element = context.SportClubs.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.SportClubs.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportClubViewModel? GetElement(SportClubSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.SportClubs.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SportClubName)) && x.SportClubName == model.SportClubName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportClubViewModel? Insert(SportClubBindingModel model)
|
||||||
|
{
|
||||||
|
var newSportClub = SportClub.Create(model);
|
||||||
|
if (newSportClub == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
context.SportClubs.Add(newSportClub);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newSportClub.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportClubViewModel? Update(SportClubBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var component = context.SportClubs.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class SportTypeStorage : ISportTypeStorage
|
||||||
|
{
|
||||||
|
public List<SportTypeViewModel> GetFilteredList(SportTypeSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.SportTypeName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.SportTypes.Where(x => x.SportTypeName.Contains(model.SportTypeName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SportTypeViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.SportTypes.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportTypeViewModel? Delete(SportTypeBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var element = context.SportTypes.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.SportTypes.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportTypeViewModel? GetElement(SportTypeSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
return context.SportTypes.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SportTypeName)) && x.SportTypeName == model.SportTypeName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportTypeViewModel? Insert(SportTypeBindingModel model)
|
||||||
|
{
|
||||||
|
var newSportType = SportType.Create(model);
|
||||||
|
if (newSportType == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
context.SportTypes.Add(newSportType);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newSportType.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportTypeViewModel? Update(SportTypeBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SportCompetitionsDatabase();
|
||||||
|
var component = context.SportTypes.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
167
SportCompetitions/SportCompetitionsDatabaseImplement/Migrations/20240521190730_InitialCreate.Designer.cs
generated
Normal file
167
SportCompetitions/SportCompetitionsDatabaseImplement/Migrations/20240521190730_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SportCompetitionsDatabaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(SportCompetitionsDatabase))]
|
||||||
|
[Migration("20240521190730_InitialCreate")]
|
||||||
|
partial class InitialCreate
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.18")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.Coach", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BirthYear")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("CoachName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Country")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("SportClubId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Coaches");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.Competition", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("CompetitionName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EndDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("Location")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("SportTypeId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("StartDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Competitions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.Participant", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BirthYear")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CoachId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CompetitionId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Country")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Gender")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("ParticipantName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Participants");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.SportClub", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("SportClubAddress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SportClubEmail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SportClubName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SportClubPhone")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SportClubs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.SportType", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("SportTypeName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SportTypes");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialCreate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Coaches",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
CoachName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
BirthYear = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Country = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
SportClubId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Coaches", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Competitions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
CompetitionName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
EndDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
Location = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
SportTypeId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Competitions", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Participants",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ParticipantName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
BirthYear = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Gender = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Country = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
CoachId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
CompetitionId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Participants", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "SportClubs",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
SportClubName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
SportClubAddress = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
SportClubEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
SportClubPhone = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_SportClubs", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "SportTypes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
SportTypeName = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_SportTypes", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Coaches");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Competitions");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Participants");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "SportClubs");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "SportTypes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,164 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SportCompetitionsDatabaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(SportCompetitionsDatabase))]
|
||||||
|
partial class SportCompetitionsDatabaseModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.18")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.Coach", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BirthYear")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("CoachName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Country")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("SportClubId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Coaches");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.Competition", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("CompetitionName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EndDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("Location")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("SportTypeId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("StartDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Competitions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.Participant", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BirthYear")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CoachId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CompetitionId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Country")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Gender")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("ParticipantName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Participants");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.SportClub", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("SportClubAddress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SportClubEmail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SportClubName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SportClubPhone")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SportClubs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SportCompetitionsDatabaseImplement.Models.SportType", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("SportTypeName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SportTypes");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
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 Coach : ICoachModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? CoachName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int BirthYear { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? Country { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int SportClubId { get; set; }
|
||||||
|
public static Coach? Create(CoachBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
return new Coach()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
CoachName = model.CoachName,
|
||||||
|
BirthYear = model.BirthYear,
|
||||||
|
Country = model.Country,
|
||||||
|
SportClubId = model.SportClubId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(CoachBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
CoachName = model.CoachName;
|
||||||
|
BirthYear = model.BirthYear;
|
||||||
|
Country = model.Country;
|
||||||
|
SportClubId = model.SportClubId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoachViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
CoachName = CoachName,
|
||||||
|
BirthYear = BirthYear,
|
||||||
|
Country = Country,
|
||||||
|
SportClubId = SportClubId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
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 Competition : ICompetitionModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? CompetitionName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
[Required]
|
||||||
|
public DateTime EndDate { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? Location { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int SportTypeId { get; set; }
|
||||||
|
public static Competition? Create(CompetitionBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
return new Competition()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
CompetitionName = model.CompetitionName,
|
||||||
|
StartDate = model.StartDate,
|
||||||
|
EndDate = model.EndDate,
|
||||||
|
Location = model.Location,
|
||||||
|
SportTypeId = model.SportTypeId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(CompetitionBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
CompetitionName = model.CompetitionName;
|
||||||
|
StartDate = model.StartDate;
|
||||||
|
EndDate = model.EndDate;
|
||||||
|
Location = model.Location;
|
||||||
|
SportTypeId = model.SportTypeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompetitionViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
CompetitionName = CompetitionName,
|
||||||
|
StartDate = StartDate,
|
||||||
|
EndDate = EndDate,
|
||||||
|
Location = Location,
|
||||||
|
SportTypeId = SportTypeId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using SportCompetitionsDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Diagnostics.Metrics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Participant : IParticipantModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? ParticipantName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int BirthYear { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? Gender { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string? Country { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int CoachId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int CompetitionId { get; set; }
|
||||||
|
public static Participant? Create(ParticipantBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
return new Participant()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ParticipantName = model.ParticipantName,
|
||||||
|
BirthYear = model.BirthYear,
|
||||||
|
Gender = model.Gender,
|
||||||
|
Country = model.Country,
|
||||||
|
CoachId = model.CoachId,
|
||||||
|
CompetitionId = model.CompetitionId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ParticipantBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
ParticipantName = model.ParticipantName;
|
||||||
|
BirthYear = model.BirthYear;
|
||||||
|
Gender = model.Gender;
|
||||||
|
Country = model.Country;
|
||||||
|
CoachId = model.CoachId;
|
||||||
|
CompetitionId = model.CompetitionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticipantViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ParticipantName = ParticipantName,
|
||||||
|
BirthYear = BirthYear,
|
||||||
|
Gender = Gender,
|
||||||
|
Country = Country,
|
||||||
|
CoachId = CoachId,
|
||||||
|
CompetitionId = CompetitionId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
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 SportClub : ISportClubModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? SportClubName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string? SportClubAddress { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string? SportClubEmail { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string? SportClubPhone { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public static SportClub? Create(SportClubBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
return new SportClub()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
SportClubName = model.SportClubName,
|
||||||
|
SportClubAddress = model.SportClubAddress,
|
||||||
|
SportClubEmail = model.SportClubEmail,
|
||||||
|
SportClubPhone = model.SportClubPhone,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(SportClubBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
SportClubName = model.SportClubName;
|
||||||
|
SportClubAddress = model.SportClubAddress;
|
||||||
|
SportClubEmail = model.SportClubEmail;
|
||||||
|
SportClubPhone = model.SportClubPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportClubViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
SportClubName = SportClubName,
|
||||||
|
SportClubAddress = SportClubAddress,
|
||||||
|
SportClubEmail = SportClubEmail,
|
||||||
|
SportClubPhone = SportClubPhone,
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
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 SportType : ISportTypeModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? SportTypeName { get; set; } = string.Empty;
|
||||||
|
public static SportType? Create(SportTypeBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
return new SportType()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
SportTypeName = model.SportTypeName,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(SportTypeBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
SportTypeName = model.SportTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SportTypeViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
SportTypeName = SportTypeName,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SportCompetitionsDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SportCompetitionsDatabaseImplement
|
||||||
|
{
|
||||||
|
public class SportCompetitionsDatabase : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-1DE5E8N\SQLEXPRESS;Initial Catalog=SportCompetitions;
|
||||||
|
Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
public virtual DbSet<Competition> Competitions { get; set; }
|
||||||
|
public virtual DbSet<Coach> Coaches { get; set; }
|
||||||
|
public virtual DbSet<Participant> Participants { get; set; }
|
||||||
|
public virtual DbSet<SportType> SportTypes { get; set; }
|
||||||
|
public virtual DbSet<SportClub> SportClubs { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SportCompetitionsBusinessLogic\SportCompetitionsBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\SportCompetitionsContracts\SportCompetitionsContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\SportCompetitionsDataModels\SportCompetitionsDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.18" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.18" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.17">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
165
SportCompetitions/SportCompetitionsView/FormCoach.Designer.cs
generated
Normal file
165
SportCompetitions/SportCompetitionsView/FormCoach.Designer.cs
generated
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormCoach
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
|
this.textBoxCountry = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxBirthYear = new System.Windows.Forms.TextBox();
|
||||||
|
this.comboBoxSportClub = new System.Windows.Forms.ComboBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(8, 36);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(45, 20);
|
||||||
|
this.label1.TabIndex = 0;
|
||||||
|
this.label1.Text = "ФИО:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(8, 90);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(111, 20);
|
||||||
|
this.label2.TabIndex = 1;
|
||||||
|
this.label2.Text = "Год рождения:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(8, 142);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(61, 20);
|
||||||
|
this.label3.TabIndex = 2;
|
||||||
|
this.label3.Text = "Страна:";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(8, 196);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(135, 20);
|
||||||
|
this.label4.TabIndex = 3;
|
||||||
|
this.label4.Text = "Спортивный клуб:";
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.Location = new System.Drawing.Point(197, 237);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.button1.TabIndex = 4;
|
||||||
|
this.button1.Text = "Сохранить";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
this.button2.Location = new System.Drawing.Point(319, 237);
|
||||||
|
this.button2.Name = "button2";
|
||||||
|
this.button2.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.button2.TabIndex = 5;
|
||||||
|
this.button2.Text = "Отмена";
|
||||||
|
this.button2.UseVisualStyleBackColor = true;
|
||||||
|
this.button2.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// textBoxCountry
|
||||||
|
//
|
||||||
|
this.textBoxCountry.Location = new System.Drawing.Point(153, 135);
|
||||||
|
this.textBoxCountry.Name = "textBoxCountry";
|
||||||
|
this.textBoxCountry.Size = new System.Drawing.Size(260, 27);
|
||||||
|
this.textBoxCountry.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(153, 36);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(260, 27);
|
||||||
|
this.textBoxName.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// textBoxBirthYear
|
||||||
|
//
|
||||||
|
this.textBoxBirthYear.Location = new System.Drawing.Point(153, 83);
|
||||||
|
this.textBoxBirthYear.Name = "textBoxBirthYear";
|
||||||
|
this.textBoxBirthYear.Size = new System.Drawing.Size(260, 27);
|
||||||
|
this.textBoxBirthYear.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// comboBoxSportClub
|
||||||
|
//
|
||||||
|
this.comboBoxSportClub.FormattingEnabled = true;
|
||||||
|
this.comboBoxSportClub.Location = new System.Drawing.Point(153, 188);
|
||||||
|
this.comboBoxSportClub.Name = "comboBoxSportClub";
|
||||||
|
this.comboBoxSportClub.Size = new System.Drawing.Size(260, 28);
|
||||||
|
this.comboBoxSportClub.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// FormCoach
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(455, 289);
|
||||||
|
this.Controls.Add(this.comboBoxSportClub);
|
||||||
|
this.Controls.Add(this.textBoxBirthYear);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.textBoxCountry);
|
||||||
|
this.Controls.Add(this.button2);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
|
this.Controls.Add(this.label4);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Name = "FormCoach";
|
||||||
|
this.Text = "Тренер";
|
||||||
|
this.Load += new System.EventHandler(this.FormCoach_Load);
|
||||||
|
this.Click += new System.EventHandler(this.FormCoach_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private Button button1;
|
||||||
|
private Button button2;
|
||||||
|
private TextBox textBoxCountry;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxBirthYear;
|
||||||
|
private ComboBox comboBoxSportClub;
|
||||||
|
}
|
||||||
|
}
|
83
SportCompetitions/SportCompetitionsView/FormCoach.cs
Normal file
83
SportCompetitions/SportCompetitionsView/FormCoach.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormCoach : Form
|
||||||
|
{
|
||||||
|
private readonly ICoachLogic _logic;
|
||||||
|
private readonly ISportTypeLogic _logicST;
|
||||||
|
private readonly List<SportTypeViewModel>? _list;
|
||||||
|
private int? _id;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set { _id = value; }
|
||||||
|
}
|
||||||
|
public FormCoach(ICoachLogic logic, ISportTypeLogic logicST)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
_logicST = logicST;
|
||||||
|
}
|
||||||
|
private void FormCoach_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var _list = _logicST.ReadList(null);
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
comboBoxSportClub.DisplayMember = "SportClubName";
|
||||||
|
comboBoxSportClub.ValueMember = "Id";
|
||||||
|
comboBoxSportClub.DataSource = _list;
|
||||||
|
comboBoxSportClub.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните Имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new CoachBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
CoachName = textBoxName.Text,
|
||||||
|
BirthYear = Convert.ToInt32(textBoxBirthYear.Text),
|
||||||
|
Country = textBoxCountry.Text,
|
||||||
|
SportClubId = comboBoxSportClub.SelectedIndex + 1,
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SportCompetitions/SportCompetitionsView/FormCoach.resx
Normal file
60
SportCompetitions/SportCompetitionsView/FormCoach.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
107
SportCompetitions/SportCompetitionsView/FormCoaches.Designer.cs
generated
Normal file
107
SportCompetitions/SportCompetitionsView/FormCoaches.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormCoaches
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonEdit = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView1.Location = new System.Drawing.Point(1, 0);
|
||||||
|
this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.dataGridView1.Name = "dataGridView1";
|
||||||
|
this.dataGridView1.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView1.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView1.Size = new System.Drawing.Size(628, 481);
|
||||||
|
this.dataGridView1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(660, 22);
|
||||||
|
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonEdit
|
||||||
|
//
|
||||||
|
this.buttonEdit.Location = new System.Drawing.Point(660, 79);
|
||||||
|
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonEdit.Name = "buttonEdit";
|
||||||
|
this.buttonEdit.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonEdit.TabIndex = 2;
|
||||||
|
this.buttonEdit.Text = "Изменить";
|
||||||
|
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonEdit.Click += new System.EventHandler(this.buttonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(660, 138);
|
||||||
|
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonDel.TabIndex = 3;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
||||||
|
//
|
||||||
|
// FormCoaches
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(786, 484);
|
||||||
|
this.Controls.Add(this.buttonDel);
|
||||||
|
this.Controls.Add(this.buttonEdit);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.dataGridView1);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormCoaches";
|
||||||
|
this.Text = "Тренеры";
|
||||||
|
this.Click += new System.EventHandler(this.FormCoaches_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView1;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonEdit;
|
||||||
|
private Button buttonDel;
|
||||||
|
}
|
||||||
|
}
|
99
SportCompetitions/SportCompetitionsView/FormCoaches.cs
Normal file
99
SportCompetitions/SportCompetitionsView/FormCoaches.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormCoaches : Form
|
||||||
|
{
|
||||||
|
private readonly ICoachLogic _logic;
|
||||||
|
|
||||||
|
public FormCoaches(ICoachLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCoaches_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView1.DataSource = list;
|
||||||
|
dataGridView1.Columns["CoachName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCoach));
|
||||||
|
if (service is FormCoach form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCoach));
|
||||||
|
if (service is FormCoach form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new CoachBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SportCompetitions/SportCompetitionsView/FormCoaches.resx
Normal file
60
SportCompetitions/SportCompetitionsView/FormCoaches.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
185
SportCompetitions/SportCompetitionsView/FormCompetition.Designer.cs
generated
Normal file
185
SportCompetitions/SportCompetitionsView/FormCompetition.Designer.cs
generated
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormCompetition
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.labelName = new System.Windows.Forms.Label();
|
||||||
|
this.labelStart = new System.Windows.Forms.Label();
|
||||||
|
this.labelEnd = new System.Windows.Forms.Label();
|
||||||
|
this.labelLocation = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxLocation = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxSportType = new System.Windows.Forms.ComboBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dateTimePicker2
|
||||||
|
//
|
||||||
|
this.dateTimePicker2.Location = new System.Drawing.Point(183, 132);
|
||||||
|
this.dateTimePicker2.Name = "dateTimePicker2";
|
||||||
|
this.dateTimePicker2.Size = new System.Drawing.Size(325, 27);
|
||||||
|
this.dateTimePicker2.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// dateTimePicker1
|
||||||
|
//
|
||||||
|
this.dateTimePicker1.Location = new System.Drawing.Point(183, 73);
|
||||||
|
this.dateTimePicker1.Name = "dateTimePicker1";
|
||||||
|
this.dateTimePicker1.Size = new System.Drawing.Size(325, 27);
|
||||||
|
this.dateTimePicker1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.AutoSize = true;
|
||||||
|
this.labelName.Location = new System.Drawing.Point(16, 24);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(80, 20);
|
||||||
|
this.labelName.TabIndex = 2;
|
||||||
|
this.labelName.Text = "Название:";
|
||||||
|
//
|
||||||
|
// labelStart
|
||||||
|
//
|
||||||
|
this.labelStart.AutoSize = true;
|
||||||
|
this.labelStart.Location = new System.Drawing.Point(16, 80);
|
||||||
|
this.labelStart.Name = "labelStart";
|
||||||
|
this.labelStart.Size = new System.Drawing.Size(97, 20);
|
||||||
|
this.labelStart.TabIndex = 3;
|
||||||
|
this.labelStart.Text = "Дата начала:";
|
||||||
|
//
|
||||||
|
// labelEnd
|
||||||
|
//
|
||||||
|
this.labelEnd.AutoSize = true;
|
||||||
|
this.labelEnd.Location = new System.Drawing.Point(16, 139);
|
||||||
|
this.labelEnd.Name = "labelEnd";
|
||||||
|
this.labelEnd.Size = new System.Drawing.Size(124, 20);
|
||||||
|
this.labelEnd.TabIndex = 4;
|
||||||
|
this.labelEnd.Text = "Дата окончания:";
|
||||||
|
//
|
||||||
|
// labelLocation
|
||||||
|
//
|
||||||
|
this.labelLocation.AutoSize = true;
|
||||||
|
this.labelLocation.Location = new System.Drawing.Point(16, 196);
|
||||||
|
this.labelLocation.Name = "labelLocation";
|
||||||
|
this.labelLocation.Size = new System.Drawing.Size(72, 20);
|
||||||
|
this.labelLocation.TabIndex = 5;
|
||||||
|
this.labelLocation.Text = "Локация:";
|
||||||
|
//
|
||||||
|
// textBoxLocation
|
||||||
|
//
|
||||||
|
this.textBoxLocation.Location = new System.Drawing.Point(183, 189);
|
||||||
|
this.textBoxLocation.Name = "textBoxLocation";
|
||||||
|
this.textBoxLocation.Size = new System.Drawing.Size(325, 27);
|
||||||
|
this.textBoxLocation.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(183, 17);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(325, 27);
|
||||||
|
this.textBoxName.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(290, 275);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(126, 29);
|
||||||
|
this.buttonSave.TabIndex = 8;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(433, 275);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(126, 29);
|
||||||
|
this.buttonCancel.TabIndex = 9;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(12, 246);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(90, 20);
|
||||||
|
this.label1.TabIndex = 10;
|
||||||
|
this.label1.Text = "Вид спорта:";
|
||||||
|
//
|
||||||
|
// comboBoxSportType
|
||||||
|
//
|
||||||
|
this.comboBoxSportType.FormattingEnabled = true;
|
||||||
|
this.comboBoxSportType.Location = new System.Drawing.Point(183, 238);
|
||||||
|
this.comboBoxSportType.Name = "comboBoxSportType";
|
||||||
|
this.comboBoxSportType.Size = new System.Drawing.Size(325, 28);
|
||||||
|
this.comboBoxSportType.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// FormCompetition
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(571, 312);
|
||||||
|
this.Controls.Add(this.comboBoxSportType);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.textBoxLocation);
|
||||||
|
this.Controls.Add(this.labelLocation);
|
||||||
|
this.Controls.Add(this.labelEnd);
|
||||||
|
this.Controls.Add(this.labelStart);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Controls.Add(this.dateTimePicker1);
|
||||||
|
this.Controls.Add(this.dateTimePicker2);
|
||||||
|
this.Name = "FormCompetition";
|
||||||
|
this.Text = "Соревнование";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DateTimePicker dateTimePicker2;
|
||||||
|
private DateTimePicker dateTimePicker1;
|
||||||
|
private Label labelName;
|
||||||
|
private Label labelStart;
|
||||||
|
private Label labelEnd;
|
||||||
|
private Label labelLocation;
|
||||||
|
private TextBox textBoxLocation;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Label label1;
|
||||||
|
private ComboBox comboBoxSportType;
|
||||||
|
}
|
||||||
|
}
|
83
SportCompetitions/SportCompetitionsView/FormCompetition.cs
Normal file
83
SportCompetitions/SportCompetitionsView/FormCompetition.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormCompetition : Form
|
||||||
|
{
|
||||||
|
private readonly ICompetitionLogic _logic;
|
||||||
|
private readonly ISportTypeLogic _logicST;
|
||||||
|
private int? _id;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set { _id = value; }
|
||||||
|
}
|
||||||
|
public FormCompetition(ICompetitionLogic logic, ISportTypeLogic logicST)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
_logicST = logicST;
|
||||||
|
}
|
||||||
|
private void FormCompetition_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var _listR = _logicST.ReadList(null);
|
||||||
|
if (_listR != null)
|
||||||
|
{
|
||||||
|
comboBoxSportType.DisplayMember = "SportTypeName";
|
||||||
|
comboBoxSportType.ValueMember = "Id";
|
||||||
|
comboBoxSportType.DataSource = _listR;
|
||||||
|
comboBoxSportType.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните Имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new CompetitionBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
CompetitionName = textBoxName.Text,
|
||||||
|
StartDate = dateTimePicker1.Value,
|
||||||
|
EndDate = dateTimePicker2.Value,
|
||||||
|
Location = textBoxLocation.Text,
|
||||||
|
SportTypeId = comboBoxSportType.SelectedIndex + 1,
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SportCompetitions/SportCompetitionsView/FormCompetition.resx
Normal file
60
SportCompetitions/SportCompetitionsView/FormCompetition.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
107
SportCompetitions/SportCompetitionsView/FormCompetitions.Designer.cs
generated
Normal file
107
SportCompetitions/SportCompetitionsView/FormCompetitions.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormCompetitions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonEdit = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView1.Location = new System.Drawing.Point(1, 0);
|
||||||
|
this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.dataGridView1.Name = "dataGridView1";
|
||||||
|
this.dataGridView1.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView1.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView1.Size = new System.Drawing.Size(628, 481);
|
||||||
|
this.dataGridView1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(660, 22);
|
||||||
|
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonEdit
|
||||||
|
//
|
||||||
|
this.buttonEdit.Location = new System.Drawing.Point(660, 79);
|
||||||
|
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonEdit.Name = "buttonEdit";
|
||||||
|
this.buttonEdit.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonEdit.TabIndex = 2;
|
||||||
|
this.buttonEdit.Text = "Изменить";
|
||||||
|
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonEdit.Click += new System.EventHandler(this.buttonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(660, 138);
|
||||||
|
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonDel.TabIndex = 3;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
||||||
|
//
|
||||||
|
// FormCompetitions
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(786, 484);
|
||||||
|
this.Controls.Add(this.buttonDel);
|
||||||
|
this.Controls.Add(this.buttonEdit);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.dataGridView1);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormCompetitions";
|
||||||
|
this.Text = "Соревнования";
|
||||||
|
this.Click += new System.EventHandler(this.FormCompetitions_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView1;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonEdit;
|
||||||
|
private Button buttonDel;
|
||||||
|
}
|
||||||
|
}
|
99
SportCompetitions/SportCompetitionsView/FormCompetitions.cs
Normal file
99
SportCompetitions/SportCompetitionsView/FormCompetitions.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormCompetitions : Form
|
||||||
|
{
|
||||||
|
private readonly ICompetitionLogic _logic;
|
||||||
|
public FormCompetitions(ICompetitionLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
private void FormCompetitions_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView1.DataSource = list;
|
||||||
|
dataGridView1.Columns["CompetitionName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["StartDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["EndDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["Location"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCompetition));
|
||||||
|
if (service is FormCompetition form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCompetition));
|
||||||
|
if (service is FormCompetition form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new CompetitionBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
135
SportCompetitions/SportCompetitionsView/FormMain.Designer.cs
generated
Normal file
135
SportCompetitions/SportCompetitionsView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormMain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.мемберToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.рекордыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.buttonCompetitions = new System.Windows.Forms.Button();
|
||||||
|
this.menuStrip1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripMenuItem1,
|
||||||
|
this.toolStripMenuItem2,
|
||||||
|
this.мемберToolStripMenuItem,
|
||||||
|
this.рекордыToolStripMenuItem});
|
||||||
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
|
this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
|
||||||
|
this.menuStrip1.Size = new System.Drawing.Size(1054, 30);
|
||||||
|
this.menuStrip1.TabIndex = 1;
|
||||||
|
this.menuStrip1.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// toolStripMenuItem1
|
||||||
|
//
|
||||||
|
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||||
|
this.toolStripMenuItem1.Size = new System.Drawing.Size(95, 24);
|
||||||
|
this.toolStripMenuItem1.Text = "Участники";
|
||||||
|
this.toolStripMenuItem1.Click += new System.EventHandler(this.ParticipantsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// toolStripMenuItem2
|
||||||
|
//
|
||||||
|
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||||
|
this.toolStripMenuItem2.Size = new System.Drawing.Size(85, 24);
|
||||||
|
this.toolStripMenuItem2.Text = "Тренеры";
|
||||||
|
this.toolStripMenuItem2.Click += new System.EventHandler(this.CoachesToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// мемберToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.мемберToolStripMenuItem.Name = "мемберToolStripMenuItem";
|
||||||
|
this.мемберToolStripMenuItem.Size = new System.Drawing.Size(101, 24);
|
||||||
|
this.мемберToolStripMenuItem.Text = "Вид спорта";
|
||||||
|
this.мемберToolStripMenuItem.Click += new System.EventHandler(this.SportTypesToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// рекордыToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.рекордыToolStripMenuItem.Name = "рекордыToolStripMenuItem";
|
||||||
|
this.рекордыToolStripMenuItem.Size = new System.Drawing.Size(146, 24);
|
||||||
|
this.рекордыToolStripMenuItem.Text = "Спортивный клуб";
|
||||||
|
this.рекордыToolStripMenuItem.Click += new System.EventHandler(this.SportClubsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 47);
|
||||||
|
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(853, 364);
|
||||||
|
this.dataGridView.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// buttonCompetitions
|
||||||
|
//
|
||||||
|
this.buttonCompetitions.Location = new System.Drawing.Point(871, 84);
|
||||||
|
this.buttonCompetitions.Name = "buttonCompetitions";
|
||||||
|
this.buttonCompetitions.Size = new System.Drawing.Size(171, 54);
|
||||||
|
this.buttonCompetitions.TabIndex = 10;
|
||||||
|
this.buttonCompetitions.Text = "Создать соревнование";
|
||||||
|
this.buttonCompetitions.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCompetitions.Click += new System.EventHandler(this.ButtonCreateCompetition_Click);
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1054, 553);
|
||||||
|
this.Controls.Add(this.buttonCompetitions);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Controls.Add(this.menuStrip1);
|
||||||
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormMain";
|
||||||
|
this.Text = "ГлавнаяФорма";
|
||||||
|
this.menuStrip1.ResumeLayout(false);
|
||||||
|
this.menuStrip1.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private MenuStrip menuStrip1;
|
||||||
|
private ToolStripMenuItem toolStripMenuItem1;
|
||||||
|
private ToolStripMenuItem toolStripMenuItem2;
|
||||||
|
private ToolStripMenuItem мемберToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem рекордыToolStripMenuItem;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonCompetitions;
|
||||||
|
}
|
||||||
|
}
|
108
SportCompetitions/SportCompetitionsView/FormMain.cs
Normal file
108
SportCompetitions/SportCompetitionsView/FormMain.cs
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsDatabaseImplement;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private ICompetitionLogic _logicC;
|
||||||
|
private ISportTypeLogic _logicT;
|
||||||
|
public FormMain(ILogger<FormMain> logger, ISportTypeLogic logicT, ICompetitionLogic logicC)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicT = logicT;
|
||||||
|
_logicC = logicC;
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicC.ReadList(null);
|
||||||
|
var listT = _logicT.ReadList(null);
|
||||||
|
if (list != null && listT != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["SportTypeId"].Visible = false;
|
||||||
|
dataGridView.Columns["SportTypeName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["CompetitionId"].Visible = false;
|
||||||
|
dataGridView.Columns["CompetitionName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["StartDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["EndDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка соревнований");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CompetitionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCompetitions));
|
||||||
|
if (service is FormCompetitions form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SportTypesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSportTypes));
|
||||||
|
if (service is FormSportTypes form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParticipantsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormParticipants));
|
||||||
|
if (service is FormParticipants form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CoachesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCoaches));
|
||||||
|
if (service is FormCoaches form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SportClubsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSportClubs));
|
||||||
|
if (service is FormSportClubs form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonCreateCompetition_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormCompetition));
|
||||||
|
if (service is FormCompetition form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
66
SportCompetitions/SportCompetitionsView/FormMain.resx
Normal file
66
SportCompetitions/SportCompetitionsView/FormMain.resx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>25</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
209
SportCompetitions/SportCompetitionsView/FormParticipant.Designer.cs
generated
Normal file
209
SportCompetitions/SportCompetitionsView/FormParticipant.Designer.cs
generated
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormParticipant
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.comboBoxCoach = new System.Windows.Forms.ComboBox();
|
||||||
|
this.comboBoxCompetition = new System.Windows.Forms.ComboBox();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxGender = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxCountry = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxBirthYear = new System.Windows.Forms.TextBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(251, 370);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonSave.TabIndex = 0;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(367, 370);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonCancel.TabIndex = 1;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// comboBoxCoach
|
||||||
|
//
|
||||||
|
this.comboBoxCoach.FormattingEnabled = true;
|
||||||
|
this.comboBoxCoach.Location = new System.Drawing.Point(171, 263);
|
||||||
|
this.comboBoxCoach.Name = "comboBoxCoach";
|
||||||
|
this.comboBoxCoach.Size = new System.Drawing.Size(290, 28);
|
||||||
|
this.comboBoxCoach.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// comboBoxCompetition
|
||||||
|
//
|
||||||
|
this.comboBoxCompetition.FormattingEnabled = true;
|
||||||
|
this.comboBoxCompetition.Location = new System.Drawing.Point(171, 321);
|
||||||
|
this.comboBoxCompetition.Name = "comboBoxCompetition";
|
||||||
|
this.comboBoxCompetition.Size = new System.Drawing.Size(290, 28);
|
||||||
|
this.comboBoxCompetition.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(16, 51);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(45, 20);
|
||||||
|
this.label1.TabIndex = 4;
|
||||||
|
this.label1.Text = "ФИО:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(16, 107);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(111, 20);
|
||||||
|
this.label2.TabIndex = 5;
|
||||||
|
this.label2.Text = "Год рождения:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(16, 155);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(61, 20);
|
||||||
|
this.label3.TabIndex = 6;
|
||||||
|
this.label3.Text = "Страна:";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(16, 213);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(40, 20);
|
||||||
|
this.label4.TabIndex = 7;
|
||||||
|
this.label4.Text = "Пол:";
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.AutoSize = true;
|
||||||
|
this.label5.Location = new System.Drawing.Point(16, 271);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(63, 20);
|
||||||
|
this.label5.TabIndex = 8;
|
||||||
|
this.label5.Text = "Тренер:";
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
this.label6.AutoSize = true;
|
||||||
|
this.label6.Location = new System.Drawing.Point(16, 329);
|
||||||
|
this.label6.Name = "label6";
|
||||||
|
this.label6.Size = new System.Drawing.Size(115, 20);
|
||||||
|
this.label6.TabIndex = 9;
|
||||||
|
this.label6.Text = "Соревнование:";
|
||||||
|
//
|
||||||
|
// textBoxGender
|
||||||
|
//
|
||||||
|
this.textBoxGender.Location = new System.Drawing.Point(171, 206);
|
||||||
|
this.textBoxGender.Name = "textBoxGender";
|
||||||
|
this.textBoxGender.Size = new System.Drawing.Size(290, 27);
|
||||||
|
this.textBoxGender.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// textBoxCountry
|
||||||
|
//
|
||||||
|
this.textBoxCountry.Location = new System.Drawing.Point(171, 155);
|
||||||
|
this.textBoxCountry.Name = "textBoxCountry";
|
||||||
|
this.textBoxCountry.Size = new System.Drawing.Size(290, 27);
|
||||||
|
this.textBoxCountry.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(171, 51);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(290, 27);
|
||||||
|
this.textBoxName.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// textBoxBirthYear
|
||||||
|
//
|
||||||
|
this.textBoxBirthYear.Location = new System.Drawing.Point(171, 100);
|
||||||
|
this.textBoxBirthYear.Name = "textBoxBirthYear";
|
||||||
|
this.textBoxBirthYear.Size = new System.Drawing.Size(290, 27);
|
||||||
|
this.textBoxBirthYear.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// FormParticipant
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(478, 414);
|
||||||
|
this.Controls.Add(this.textBoxBirthYear);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.textBoxCountry);
|
||||||
|
this.Controls.Add(this.textBoxGender);
|
||||||
|
this.Controls.Add(this.label6);
|
||||||
|
this.Controls.Add(this.label5);
|
||||||
|
this.Controls.Add(this.label4);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.comboBoxCompetition);
|
||||||
|
this.Controls.Add(this.comboBoxCoach);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Name = "FormParticipant";
|
||||||
|
this.Text = "Участник";
|
||||||
|
this.Load += new System.EventHandler(this.FormParticipant_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private ComboBox comboBoxCoach;
|
||||||
|
private ComboBox comboBoxCompetition;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private Label label5;
|
||||||
|
private Label label6;
|
||||||
|
private TextBox textBoxGender;
|
||||||
|
private TextBox textBoxCountry;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxBirthYear;
|
||||||
|
}
|
||||||
|
}
|
93
SportCompetitions/SportCompetitionsView/FormParticipant.cs
Normal file
93
SportCompetitions/SportCompetitionsView/FormParticipant.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormParticipant : Form
|
||||||
|
{
|
||||||
|
private readonly IParticipantLogic _logic;
|
||||||
|
private readonly ICoachLogic _logicC;
|
||||||
|
private readonly ICompetitionLogic _logicCN;
|
||||||
|
private int? _id;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set { _id = value; }
|
||||||
|
}
|
||||||
|
public FormParticipant(IParticipantLogic logic, ICoachLogic logicC, ICompetitionLogic logicCN)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
_logicC = logicC;
|
||||||
|
_logicCN = logicCN;
|
||||||
|
}
|
||||||
|
private void FormParticipant_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var _listP = _logicC.ReadList(null);
|
||||||
|
if (_listP != null)
|
||||||
|
{
|
||||||
|
comboBoxCoach.DisplayMember = "CoachName";
|
||||||
|
comboBoxCoach.ValueMember = "Id";
|
||||||
|
comboBoxCoach.DataSource = _listP;
|
||||||
|
comboBoxCoach.SelectedItem = null;
|
||||||
|
}
|
||||||
|
var _listR = _logicCN.ReadList(null);
|
||||||
|
if (_listR != null)
|
||||||
|
{
|
||||||
|
comboBoxCompetition.DisplayMember = "CompetitionName";
|
||||||
|
comboBoxCompetition.ValueMember = "Id";
|
||||||
|
comboBoxCompetition.DataSource = _listR;
|
||||||
|
comboBoxCompetition.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните Имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ParticipantBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ParticipantName = textBoxName.Text,
|
||||||
|
BirthYear = Convert.ToInt32(textBoxBirthYear.Text),
|
||||||
|
Country = textBoxCountry.Text,
|
||||||
|
Gender = textBoxGender.Text,
|
||||||
|
CoachId = comboBoxCoach.SelectedIndex + 1,
|
||||||
|
CompetitionId = comboBoxCompetition.SelectedIndex + 1
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SportCompetitions/SportCompetitionsView/FormParticipant.resx
Normal file
60
SportCompetitions/SportCompetitionsView/FormParticipant.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
107
SportCompetitions/SportCompetitionsView/FormParticipants.Designer.cs
generated
Normal file
107
SportCompetitions/SportCompetitionsView/FormParticipants.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormParticipants
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonEdit = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView1.Location = new System.Drawing.Point(1, 0);
|
||||||
|
this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.dataGridView1.Name = "dataGridView1";
|
||||||
|
this.dataGridView1.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView1.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView1.Size = new System.Drawing.Size(628, 481);
|
||||||
|
this.dataGridView1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(660, 22);
|
||||||
|
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonEdit
|
||||||
|
//
|
||||||
|
this.buttonEdit.Location = new System.Drawing.Point(660, 79);
|
||||||
|
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonEdit.Name = "buttonEdit";
|
||||||
|
this.buttonEdit.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonEdit.TabIndex = 2;
|
||||||
|
this.buttonEdit.Text = "Изменить";
|
||||||
|
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonEdit.Click += new System.EventHandler(this.buttonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(660, 138);
|
||||||
|
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonDel.TabIndex = 3;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
||||||
|
//
|
||||||
|
// FormParticipants
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(786, 484);
|
||||||
|
this.Controls.Add(this.buttonDel);
|
||||||
|
this.Controls.Add(this.buttonEdit);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.dataGridView1);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormParticipants";
|
||||||
|
this.Text = "Участники";
|
||||||
|
this.Click += new System.EventHandler(this.FormParticipants_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView1;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonEdit;
|
||||||
|
private Button buttonDel;
|
||||||
|
}
|
||||||
|
}
|
99
SportCompetitions/SportCompetitionsView/FormParticipants.cs
Normal file
99
SportCompetitions/SportCompetitionsView/FormParticipants.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormParticipants : Form
|
||||||
|
{
|
||||||
|
private readonly IParticipantLogic _logic;
|
||||||
|
|
||||||
|
public FormParticipants(IParticipantLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormParticipants_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView1.DataSource = list;
|
||||||
|
dataGridView1.Columns["ParticipantName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormParticipant));
|
||||||
|
if (service is FormParticipant form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormParticipant));
|
||||||
|
if (service is FormParticipant form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new ParticipantBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
163
SportCompetitions/SportCompetitionsView/FormSportClub.Designer.cs
generated
Normal file
163
SportCompetitions/SportCompetitionsView/FormSportClub.Designer.cs
generated
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormSportClub
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxPhone = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxEmail = new System.Windows.Forms.TextBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(277, 273);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonSave.TabIndex = 0;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(395, 273);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonCancel.TabIndex = 1;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(16, 220);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(51, 20);
|
||||||
|
this.label1.TabIndex = 2;
|
||||||
|
this.label1.Text = "Почта";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(16, 59);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(80, 20);
|
||||||
|
this.label2.TabIndex = 3;
|
||||||
|
this.label2.Text = "Название:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(16, 118);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(54, 20);
|
||||||
|
this.label3.TabIndex = 4;
|
||||||
|
this.label3.Text = "Адрес:";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(16, 168);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(69, 20);
|
||||||
|
this.label4.TabIndex = 5;
|
||||||
|
this.label4.Text = "Телефон";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(137, 52);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(323, 27);
|
||||||
|
this.textBoxName.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// textBoxAddress
|
||||||
|
//
|
||||||
|
this.textBoxAddress.Location = new System.Drawing.Point(137, 111);
|
||||||
|
this.textBoxAddress.Name = "textBoxAddress";
|
||||||
|
this.textBoxAddress.Size = new System.Drawing.Size(323, 27);
|
||||||
|
this.textBoxAddress.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// textBoxPhone
|
||||||
|
//
|
||||||
|
this.textBoxPhone.Location = new System.Drawing.Point(137, 161);
|
||||||
|
this.textBoxPhone.Name = "textBoxPhone";
|
||||||
|
this.textBoxPhone.Size = new System.Drawing.Size(323, 27);
|
||||||
|
this.textBoxPhone.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// textBoxEmail
|
||||||
|
//
|
||||||
|
this.textBoxEmail.Location = new System.Drawing.Point(137, 213);
|
||||||
|
this.textBoxEmail.Name = "textBoxEmail";
|
||||||
|
this.textBoxEmail.Size = new System.Drawing.Size(323, 27);
|
||||||
|
this.textBoxEmail.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// FormSportClub
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(501, 314);
|
||||||
|
this.Controls.Add(this.textBoxEmail);
|
||||||
|
this.Controls.Add(this.textBoxPhone);
|
||||||
|
this.Controls.Add(this.textBoxAddress);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.label4);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Name = "FormSportClub";
|
||||||
|
this.Text = "Спортивный клуб";
|
||||||
|
this.Load += new System.EventHandler(this.FormSportClub_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxAddress;
|
||||||
|
private TextBox textBoxPhone;
|
||||||
|
private TextBox textBoxEmail;
|
||||||
|
}
|
||||||
|
}
|
88
SportCompetitions/SportCompetitionsView/FormSportClub.cs
Normal file
88
SportCompetitions/SportCompetitionsView/FormSportClub.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormSportClub : Form
|
||||||
|
{
|
||||||
|
private ISportClubLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public FormSportClub(ISportClubLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
private void FormSportClub_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new SportClubSearchModel { Id = _id.Value });
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.SportClubName;
|
||||||
|
textBoxAddress.Text = view.SportClubAddress;
|
||||||
|
textBoxPhone.Text = view.SportClubPhone;
|
||||||
|
textBoxEmail.Text = view.SportClubEmail;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new SportClubBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
SportClubName = textBoxName.Text,
|
||||||
|
SportClubAddress = textBoxAddress.Text,
|
||||||
|
SportClubPhone = textBoxPhone.Text,
|
||||||
|
SportClubEmail = textBoxEmail.Text,
|
||||||
|
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SportCompetitions/SportCompetitionsView/FormSportClub.resx
Normal file
60
SportCompetitions/SportCompetitionsView/FormSportClub.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
107
SportCompetitions/SportCompetitionsView/FormSportClubs.Designer.cs
generated
Normal file
107
SportCompetitions/SportCompetitionsView/FormSportClubs.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormSportClubs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonEdit = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView1.Location = new System.Drawing.Point(1, 0);
|
||||||
|
this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.dataGridView1.Name = "dataGridView1";
|
||||||
|
this.dataGridView1.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView1.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView1.Size = new System.Drawing.Size(628, 481);
|
||||||
|
this.dataGridView1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(660, 22);
|
||||||
|
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonEdit
|
||||||
|
//
|
||||||
|
this.buttonEdit.Location = new System.Drawing.Point(660, 79);
|
||||||
|
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonEdit.Name = "buttonEdit";
|
||||||
|
this.buttonEdit.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonEdit.TabIndex = 2;
|
||||||
|
this.buttonEdit.Text = "Изменить";
|
||||||
|
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonEdit.Click += new System.EventHandler(this.buttonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(660, 138);
|
||||||
|
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonDel.TabIndex = 3;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
||||||
|
//
|
||||||
|
// FormSportClubs
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(786, 484);
|
||||||
|
this.Controls.Add(this.buttonDel);
|
||||||
|
this.Controls.Add(this.buttonEdit);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.dataGridView1);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormSportClubs";
|
||||||
|
this.Text = "Спортивные клубы";
|
||||||
|
this.Load += new System.EventHandler(this.FormSportClubs_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView1;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonEdit;
|
||||||
|
private Button buttonDel;
|
||||||
|
}
|
||||||
|
}
|
99
SportCompetitions/SportCompetitionsView/FormSportClubs.cs
Normal file
99
SportCompetitions/SportCompetitionsView/FormSportClubs.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormSportClubs : Form
|
||||||
|
{
|
||||||
|
private readonly ISportClubLogic _logic;
|
||||||
|
|
||||||
|
public FormSportClubs(ISportClubLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormSportClubs_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView1.DataSource = list;
|
||||||
|
dataGridView1.Columns["SportClubName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSportClub));
|
||||||
|
if (service is FormSportClub form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSportClub));
|
||||||
|
if (service is FormSportClub form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new SportClubBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SportCompetitions/SportCompetitionsView/FormSportClubs.resx
Normal file
60
SportCompetitions/SportCompetitionsView/FormSportClubs.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
96
SportCompetitions/SportCompetitionsView/FormSportType.Designer.cs
generated
Normal file
96
SportCompetitions/SportCompetitionsView/FormSportType.Designer.cs
generated
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormSportType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.labelName = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.AutoSize = true;
|
||||||
|
this.labelName.Location = new System.Drawing.Point(12, 29);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(80, 20);
|
||||||
|
this.labelName.TabIndex = 0;
|
||||||
|
this.labelName.Text = "Название:";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(103, 22);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(230, 27);
|
||||||
|
this.textBoxName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(103, 77);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonSave.TabIndex = 2;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(222, 77);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonCancel.TabIndex = 3;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// FormSportType
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(345, 142);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Name = "FormSportType";
|
||||||
|
this.Text = "Вид спорта";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
80
SportCompetitions/SportCompetitionsView/FormSportType.cs
Normal file
80
SportCompetitions/SportCompetitionsView/FormSportType.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormSportType : Form
|
||||||
|
{
|
||||||
|
private ISportTypeLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public FormSportType(ISportTypeLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
private void FormSportType_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new SportTypeSearchModel { Id = _id.Value });
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.SportTypeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new SportTypeBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
SportTypeName = textBoxName.Text,
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SportCompetitions/SportCompetitionsView/FormSportType.resx
Normal file
60
SportCompetitions/SportCompetitionsView/FormSportType.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
107
SportCompetitions/SportCompetitionsView/FormSportTypes.Designer.cs
generated
Normal file
107
SportCompetitions/SportCompetitionsView/FormSportTypes.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
partial class FormSportTypes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonEdit = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView1.Location = new System.Drawing.Point(1, 0);
|
||||||
|
this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.dataGridView1.Name = "dataGridView1";
|
||||||
|
this.dataGridView1.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView1.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView1.Size = new System.Drawing.Size(628, 481);
|
||||||
|
this.dataGridView1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(660, 22);
|
||||||
|
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonEdit
|
||||||
|
//
|
||||||
|
this.buttonEdit.Location = new System.Drawing.Point(660, 79);
|
||||||
|
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonEdit.Name = "buttonEdit";
|
||||||
|
this.buttonEdit.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonEdit.TabIndex = 2;
|
||||||
|
this.buttonEdit.Text = "Изменить";
|
||||||
|
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonEdit.Click += new System.EventHandler(this.buttonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(660, 138);
|
||||||
|
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(110, 36);
|
||||||
|
this.buttonDel.TabIndex = 3;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
||||||
|
//
|
||||||
|
// FormSportTypes
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(786, 484);
|
||||||
|
this.Controls.Add(this.buttonDel);
|
||||||
|
this.Controls.Add(this.buttonEdit);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.dataGridView1);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormSportTypes";
|
||||||
|
this.Text = "Виды спорта";
|
||||||
|
this.Load += new System.EventHandler(this.FormSportTypes_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView1;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonEdit;
|
||||||
|
private Button buttonDel;
|
||||||
|
}
|
||||||
|
}
|
97
SportCompetitions/SportCompetitionsView/FormSportTypes.cs
Normal file
97
SportCompetitions/SportCompetitionsView/FormSportTypes.cs
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
|
using SportCompetitionsContracts.BindingModels;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
public partial class FormSportTypes : Form
|
||||||
|
{
|
||||||
|
private readonly ISportTypeLogic _logic;
|
||||||
|
public FormSportTypes(ISportTypeLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
public void FormSportTypes_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView1.DataSource = list;
|
||||||
|
dataGridView1.Columns["SportTypeName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSportType));
|
||||||
|
if (service is FormSportType form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSportType));
|
||||||
|
if (service is FormSportType form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new SportTypeBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SportCompetitions/SportCompetitionsView/FormSportTypes.resx
Normal file
60
SportCompetitions/SportCompetitionsView/FormSportTypes.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
69
SportCompetitions/SportCompetitionsView/Program.cs
Normal file
69
SportCompetitions/SportCompetitionsView/Program.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using SportCompetitionsBusinessLogic.BusinessLogics;
|
||||||
|
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||||
|
using SportCompetitionsContracts.StoragesContracts;
|
||||||
|
using SportCompetitionsDatabaseImplement.Implements;
|
||||||
|
using NLog.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace SportCompetitionsView
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
private static ServiceProvider? _serviceProvider;
|
||||||
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddLogging(option =>
|
||||||
|
{
|
||||||
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
|
option.AddNLog("nlog.config");
|
||||||
|
});
|
||||||
|
services.AddTransient<ICompetitionStorage, CompetitionStorage>();
|
||||||
|
services.AddTransient<ICoachStorage, CoachStorage>();
|
||||||
|
services.AddTransient<IParticipantStorage, ParticipantStorage>();
|
||||||
|
services.AddTransient<ISportTypeStorage, SportTypeStorage>();
|
||||||
|
services.AddTransient<ISportClubStorage, SportClubStorage>();
|
||||||
|
|
||||||
|
services.AddTransient<ICompetitionLogic, CompetitionLogic>();
|
||||||
|
services.AddTransient<ICoachLogic, CoachLogic>();
|
||||||
|
services.AddTransient<IParticipantLogic, ParticipantLogic>();
|
||||||
|
services.AddTransient<ISportTypeLogic, SportTypeLogic>();
|
||||||
|
services.AddTransient<ISportClubLogic, SportClubLogic>();
|
||||||
|
|
||||||
|
services.AddTransient<FormMain>();
|
||||||
|
|
||||||
|
services.AddTransient<FormCoach>();
|
||||||
|
services.AddTransient<FormCoaches>();
|
||||||
|
|
||||||
|
services.AddTransient<FormCompetition>();
|
||||||
|
services.AddTransient<FormCompetitions>();
|
||||||
|
|
||||||
|
services.AddTransient<FormSportClub>();
|
||||||
|
services.AddTransient<FormSportClubs>();
|
||||||
|
|
||||||
|
services.AddTransient<FormParticipant>();
|
||||||
|
services.AddTransient<FormParticipants>();
|
||||||
|
|
||||||
|
services.AddTransient<FormSportType>();
|
||||||
|
services.AddTransient<FormSportTypes>();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
63
SportCompetitions/SportCompetitionsView/Properties/Resources.Designer.cs
generated
Normal file
63
SportCompetitions/SportCompetitionsView/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace SportCompetitionsView.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||||
|
/// </summary>
|
||||||
|
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||||
|
// с помощью такого средства, как ResGen или Visual Studio.
|
||||||
|
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||||
|
// с параметром /str или перестройте свой проект VS.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SportCompetitionsView.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||||
|
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -0,0 +1,44 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.18" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.17">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SportCompetitionsBusinessLogic\SportCompetitionsBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\SportCompetitionsContracts\SportCompetitionsContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\SportCompetitionsDatabaseImplement\SportCompetitionsDatabaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\SportCompetitionsDataModels\SportCompetitionsDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
15
SportCompetitions/SportCompetitionsView/nlog.config
Normal file
15
SportCompetitions/SportCompetitionsView/nlog.config
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
autoReload="true" internalLogLevel="Info">
|
||||||
|
|
||||||
|
<targets>
|
||||||
|
<target xsi:type="File" name="tofile" fileName="log-${shortdate}.log" />
|
||||||
|
</targets>
|
||||||
|
|
||||||
|
<rules>
|
||||||
|
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue
Block a user