Сделал модельки в базе данных, а так же начал имплементс
This commit is contained in:
parent
ce3068308f
commit
2a460af5cc
@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelContracts", "HotelCont
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelBusinessLogic", "HotelBusinessLogic\HotelBusinessLogic.csproj", "{66786012-F68B-4515-9C19-4C97049F9C49}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelDatabaseImplement", "HotelDatabaseImplement\HotelDatabaseImplement.csproj", "{90B9109F-0F4A-4940-A45F-37839F2F773B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -33,6 +35,10 @@ Global
|
||||
{66786012-F68B-4515-9C19-4C97049F9C49}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{66786012-F68B-4515-9C19-4C97049F9C49}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{66786012-F68B-4515-9C19-4C97049F9C49}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{90B9109F-0F4A-4940-A45F-37839F2F773B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{90B9109F-0F4A-4940-A45F-37839F2F773B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{90B9109F-0F4A-4940-A45F-37839F2F773B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{90B9109F-0F4A-4940-A45F-37839F2F773B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
27
Hotel/HotelDatabaseImplement/HotelDataBase.cs
Normal file
27
Hotel/HotelDatabaseImplement/HotelDataBase.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using HotelDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement
|
||||
{
|
||||
public class HotelDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=TestProject;Integrated Security=True;MultipleActiveResultSets=True;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Booking> Bookings { get; set; }
|
||||
public virtual DbSet<Client> Clients { get; set; }
|
||||
public virtual DbSet<Post> Posts { get; set; }
|
||||
public virtual DbSet<Room> Rooms { get; set; }
|
||||
public virtual DbSet<Worker> Workers { get; set; }
|
||||
}
|
||||
}
|
25
Hotel/HotelDatabaseImplement/HotelDatabaseImplement.csproj
Normal file
25
Hotel/HotelDatabaseImplement/HotelDatabaseImplement.csproj
Normal file
@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.16" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.16" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.16">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HotelBusinessLogic\HotelBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\HotelContracts\HotelContracts.csproj" />
|
||||
<ProjectReference Include="..\HotelDataModels\HotelDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
17
Hotel/HotelDatabaseImplement/Implements/BookingStorage.cs
Normal file
17
Hotel/HotelDatabaseImplement/Implements/BookingStorage.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Implements
|
||||
{
|
||||
public class BookingStorage : IBookingStorage
|
||||
{
|
||||
|
||||
}
|
||||
}
|
13
Hotel/HotelDatabaseImplement/Implements/ClientStorage.cs
Normal file
13
Hotel/HotelDatabaseImplement/Implements/ClientStorage.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using HotelContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
}
|
||||
}
|
13
Hotel/HotelDatabaseImplement/Implements/PostStorage.cs
Normal file
13
Hotel/HotelDatabaseImplement/Implements/PostStorage.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using HotelContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Implements
|
||||
{
|
||||
public class PostStorage : IPostStorage
|
||||
{
|
||||
}
|
||||
}
|
13
Hotel/HotelDatabaseImplement/Implements/RoomStorage.cs
Normal file
13
Hotel/HotelDatabaseImplement/Implements/RoomStorage.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using HotelContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Implements
|
||||
{
|
||||
public class RoomStorage : IRoomStorage
|
||||
{
|
||||
}
|
||||
}
|
13
Hotel/HotelDatabaseImplement/Implements/WorkerStorage.cs
Normal file
13
Hotel/HotelDatabaseImplement/Implements/WorkerStorage.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using HotelContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Implements
|
||||
{
|
||||
public class WorkerStorage : IWorkerStorage
|
||||
{
|
||||
}
|
||||
}
|
70
Hotel/HotelDatabaseImplement/Models/Booking.cs
Normal file
70
Hotel/HotelDatabaseImplement/Models/Booking.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Enums;
|
||||
using HotelDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Models
|
||||
{
|
||||
public class Booking : IBookingModel
|
||||
{
|
||||
[Required]
|
||||
public int RoomId { get; set; }
|
||||
[Required]
|
||||
public int ClientId { get; set; }
|
||||
[Required]
|
||||
public DateTime ArrivalDate { get; set; }
|
||||
[Required]
|
||||
public DateTime DepartureDate { get; set; }
|
||||
[Required]
|
||||
public int NumberHoursSpent { get; set; }
|
||||
[Required]
|
||||
public AcceptanceStatus Status { get; set; }
|
||||
[Required]
|
||||
public int TotalCost { get; set; }
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
public static Booking Create(BookingBindingModel model)
|
||||
{
|
||||
return new Booking()
|
||||
{
|
||||
Id = model.Id,
|
||||
RoomId = model.RoomId,
|
||||
ClientId = model.ClientId,
|
||||
ArrivalDate = model.ArrivalDate,
|
||||
DepartureDate = model.DepartureDate,
|
||||
NumberHoursSpent = model.NumberHoursSpent,
|
||||
Status = model.Status,
|
||||
TotalCost = model.TotalCost,
|
||||
};
|
||||
}
|
||||
public void Update(BookingBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
Id = model.Id;
|
||||
RoomId = model.RoomId;
|
||||
ClientId = model.ClientId;
|
||||
ArrivalDate = model.ArrivalDate;
|
||||
DepartureDate = model.DepartureDate;
|
||||
NumberHoursSpent = model.NumberHoursSpent;
|
||||
Status = model.Status;
|
||||
TotalCost = model.TotalCost;
|
||||
}
|
||||
public BookingViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
RoomId = RoomId,
|
||||
ClientId = ClientId,
|
||||
ArrivalDate = ArrivalDate,
|
||||
DepartureDate = DepartureDate,
|
||||
NumberHoursSpent = NumberHoursSpent,
|
||||
Status = Status,
|
||||
TotalCost = TotalCost
|
||||
};
|
||||
}
|
||||
}
|
59
Hotel/HotelDatabaseImplement/Models/Client.cs
Normal file
59
Hotel/HotelDatabaseImplement/Models/Client.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
[Required]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
public static Client Create(HotelDatabase context, ClientBindingModel model)
|
||||
{
|
||||
return new Client()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Surname = model.Surname,
|
||||
DateOfBirth = model.DateOfBirth,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Password = model.Password,
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
Id = model.Id;
|
||||
Name = model.Name;
|
||||
Surname = model.Surname;
|
||||
DateOfBirth = model.DateOfBirth;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
Password = model.Password;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Surname = Surname,
|
||||
DateOfBirth = DateOfBirth,
|
||||
PhoneNumber = PhoneNumber,
|
||||
Password = Password
|
||||
};
|
||||
}
|
||||
}
|
43
Hotel/HotelDatabaseImplement/Models/Post.cs
Normal file
43
Hotel/HotelDatabaseImplement/Models/Post.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Models
|
||||
{
|
||||
public class Post : IPostModel
|
||||
{
|
||||
[Required]
|
||||
public string PostName { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
public static Post? Create(PostBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
return new Post()
|
||||
{
|
||||
Id = model.Id,
|
||||
PostName = model.PostName
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(PostBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
Id = model.Id;
|
||||
PostName = model.PostName;
|
||||
}
|
||||
|
||||
public PostViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PostName = PostName
|
||||
};
|
||||
}
|
||||
}
|
69
Hotel/HotelDatabaseImplement/Models/Room.cs
Normal file
69
Hotel/HotelDatabaseImplement/Models/Room.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Models
|
||||
{
|
||||
public class Room : IRoomModel
|
||||
{
|
||||
[Required]
|
||||
public int WorkerId { get; set; }
|
||||
[Required]
|
||||
public int Number { get; set; }
|
||||
[Required]
|
||||
public int Floor { get; set; }
|
||||
[Required]
|
||||
public int NumberOfBeds { get; set; }
|
||||
[Required]
|
||||
public string Condition { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int Cost { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public static Room? Create(RoomBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
return new Room()
|
||||
{
|
||||
Id = model.Id,
|
||||
WorkerId = model.WorkerId,
|
||||
Number = model.Number,
|
||||
NumberOfBeds = model.NumberOfBeds,
|
||||
Condition = model.Condition,
|
||||
Cost = model.Cost,
|
||||
Floor = model.Floor
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(RoomBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
Id = model.Id;
|
||||
WorkerId = model.WorkerId;
|
||||
Number = model.Number;
|
||||
NumberOfBeds = model.NumberOfBeds;
|
||||
Condition = model.Condition;
|
||||
Cost = model.Cost;
|
||||
Floor = model.Floor;
|
||||
|
||||
}
|
||||
|
||||
public RoomViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
WorkerId = WorkerId,
|
||||
Number = Number,
|
||||
NumberOfBeds = NumberOfBeds,
|
||||
Condition = Condition,
|
||||
Cost = Cost,
|
||||
Floor = Floor
|
||||
};
|
||||
}
|
||||
}
|
66
Hotel/HotelDatabaseImplement/Models/Worker.cs
Normal file
66
Hotel/HotelDatabaseImplement/Models/Worker.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HotelDatabaseImplement.Models
|
||||
{
|
||||
public class Worker : IWorkerModel
|
||||
{
|
||||
public int PostId { get; set; }
|
||||
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
public int Salary { get; set; }
|
||||
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
public static Worker? Create(WorkerBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
return new Worker()
|
||||
{
|
||||
Id = model.Id,
|
||||
PostId = model.PostId,
|
||||
FIO = model.FIO,
|
||||
DateOfBirth = model.DateOfBirth,
|
||||
WorkExperience = model.WorkExperience,
|
||||
Salary = model.Salary,
|
||||
Phone = model.Phone
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(WorkerBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
Id = model.Id;
|
||||
PostId = model.PostId;
|
||||
FIO = model.FIO;
|
||||
DateOfBirth = model.DateOfBirth;
|
||||
WorkExperience = model.WorkExperience;
|
||||
Salary = model.Salary;
|
||||
Phone = model.Phone;
|
||||
}
|
||||
|
||||
public WorkerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PostId = PostId,
|
||||
FIO = FIO,
|
||||
DateOfBirth = DateOfBirth,
|
||||
WorkExperience = WorkExperience,
|
||||
Salary = Salary,
|
||||
Phone = Phone
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user