Делаем десираилазцию данных

This commit is contained in:
Вячеслав Иванов 2024-03-23 18:43:34 +04:00
parent e7701b5284
commit a9d47cecc1
4 changed files with 28 additions and 4 deletions

View File

@ -3,13 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.9.34622.214 VisualStudioVersion = 17.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelView", "HotelView\HotelView.csproj", "{6178B3A4-FD96-4706-BA98-85A1B348544F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelView", "HotelView\HotelView.csproj", "{6178B3A4-FD96-4706-BA98-85A1B348544F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelDataModels", "HotelDataModels\HotelDataModels.csproj", "{CA43CA92-EB41-4E16-AE45-8D6E72819F8C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelDataModels", "HotelDataModels\HotelDataModels.csproj", "{CA43CA92-EB41-4E16-AE45-8D6E72819F8C}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelContracts", "HotelContracts\HotelContracts.csproj", "{BF2AB478-A809-4A22-AA0A-A655BC9628B8}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelContracts", "HotelContracts\HotelContracts.csproj", "{BF2AB478-A809-4A22-AA0A-A655BC9628B8}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelDataBaseImplement", "HotelDataBaseImplement\HotelDataBaseImplement.csproj", "{3FAD978F-2155-4D65-963D-616F18ABA37F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelDataBaseImplement", "HotelDataBaseImplement\HotelDataBaseImplement.csproj", "{3FAD978F-2155-4D65-963D-616F18ABA37F}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -6,6 +6,10 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\HotelDataModels\HotelDataModels.csproj" /> <ProjectReference Include="..\HotelDataModels\HotelDataModels.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -1,4 +1,5 @@
using HotelDataModels.Models; using HotelDataModels.Models;
using Newtonsoft.Json;
using System.ComponentModel; using System.ComponentModel;
namespace HotelContracts.ViewModels namespace HotelContracts.ViewModels
@ -16,5 +17,15 @@ namespace HotelContracts.ViewModels
public string NameHall { get; set; } = string.Empty; public string NameHall { get; set; } = string.Empty;
public Dictionary<int, ILunchModel> ConferenceBookingLunches { get; set; } public Dictionary<int, ILunchModel> ConferenceBookingLunches { get; set; }
public Dictionary<int, IConferenceBookingModel> ConferenceConferenceBookings { get; set; } = new();
public ConferenceBookingViewModel() { }
[JsonConstructor]
public ConferenceBookingViewModel(Dictionary<int, LunchViewModel> ConferenceBookingDinners, Dictionary<int, ConferenceBookingViewModel> ConferenceConferenceBookings)
{
this.ConferenceBookingLunches = ConferenceBookingDinners.ToDictionary(x => x.Key, x => x.Value as ILunchModel);
this.ConferenceConferenceBookings = ConferenceConferenceBookings.ToDictionary(x => x.Key, x => x.Value as IConferenceBookingModel);
}
} }
} }

View File

@ -1,4 +1,5 @@
using HotelDataModels.Models; using HotelDataModels.Models;
using Newtonsoft.Json;
using System.ComponentModel; using System.ComponentModel;
namespace HotelContracts.ViewModels namespace HotelContracts.ViewModels
@ -21,5 +22,13 @@ namespace HotelContracts.ViewModels
public int HeadwaiterId { get; set; } public int HeadwaiterId { get; set; }
public Dictionary<int, ILunchModel> RoomLunches { get; set; } public Dictionary<int, ILunchModel> RoomLunches { get; set; }
public RoomViewModel() { }
[JsonConstructor]
public RoomViewModel(Dictionary<int, LunchViewModel> RoomDinners)
{
this.RoomLunches = RoomDinners.ToDictionary(x => x.Key, x => x.Value as ILunchModel);
}
} }
} }