Merge branch 'CourseWork' of http://student.git.athene.tech/AnnZhimol/CourseWork_Hotel into CourseWork
This commit is contained in:
commit
a0760de3e5
@ -11,11 +11,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelContracts", "HotelCont
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelDataBaseImplement", "HotelDataBaseImplement\HotelDataBaseImplement.csproj", "{B32CB19B-0F73-49F1-8821-7BBAFED6A6C5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelBusinessLogic", "HotelBusinessLogic\HotelBusinessLogic.csproj", "{E34AD471-B0B3-473F-9A52-E7BB20CA1081}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelBusinessLogic", "HotelBusinessLogic\HotelBusinessLogic.csproj", "{E34AD471-B0B3-473F-9A52-E7BB20CA1081}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelRestApi", "HotelRestApi\HotelRestApi.csproj", "{1D7D511E-66E9-480F-92B9-9E1A33916DCF}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelRestApi", "HotelRestApi\HotelRestApi.csproj", "{1D7D511E-66E9-480F-92B9-9E1A33916DCF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelHeadwaiterApp", "HostrelHeadwaiterApp\HotelHeadwaiterApp.csproj", "{9F25F6AF-2887-467D-B4F1-E3805772124D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelHeadwaiterApp", "HostrelHeadwaiterApp\HotelHeadwaiterApp.csproj", "{9F25F6AF-2887-467D-B4F1-E3805772124D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -39,6 +39,18 @@ Global
|
||||
{B32CB19B-0F73-49F1-8821-7BBAFED6A6C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B32CB19B-0F73-49F1-8821-7BBAFED6A6C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B32CB19B-0F73-49F1-8821-7BBAFED6A6C5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E34AD471-B0B3-473F-9A52-E7BB20CA1081}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E34AD471-B0B3-473F-9A52-E7BB20CA1081}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E34AD471-B0B3-473F-9A52-E7BB20CA1081}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E34AD471-B0B3-473F-9A52-E7BB20CA1081}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D7D511E-66E9-480F-92B9-9E1A33916DCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D7D511E-66E9-480F-92B9-9E1A33916DCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D7D511E-66E9-480F-92B9-9E1A33916DCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D7D511E-66E9-480F-92B9-9E1A33916DCF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9F25F6AF-2887-467D-B4F1-E3805772124D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9F25F6AF-2887-467D-B4F1-E3805772124D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9F25F6AF-2887-467D-B4F1-E3805772124D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9F25F6AF-2887-467D-B4F1-E3805772124D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,35 +1,120 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ConferenceLogic : IConferenceLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IConferenceStorage _conferenceStorage;
|
||||
|
||||
public ConferenceLogic(ILogger<ConferenceLogic> logger, IConferenceStorage conferenceStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_conferenceStorage = conferenceStorage;
|
||||
}
|
||||
public bool Create(ConferenceBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CheckModel(model);
|
||||
|
||||
if (_conferenceStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ConferenceBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_conferenceStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ConferenceViewModel? ReadElement(ConferenceSearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ConferenceName:{ConferenceName}.Id:{Id}", model.ConferenceName, model.Id);
|
||||
|
||||
var element = _conferenceStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ConferenceViewModel>? ReadList(ConferenceSearchModel? model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_logger.LogInformation("ReadList. ConferenceName:{ConferenceName}.Id:{ Id}", model?.ConferenceName, model?.Id);
|
||||
|
||||
var list = model == null ? _conferenceStorage.GetFullList() : _conferenceStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(ConferenceBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CheckModel(model);
|
||||
|
||||
if (_conferenceStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ConferenceBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ConferenceName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия конференции", nameof(model.ConferenceName));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Conference. ConferenceName:{ConferenceName}.StartDate:{ StartDate}. Id: { Id}", model.ConferenceName, model.StartDate, model.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,135 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class MealPlanLogic : IMealPlanLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMealPlanStorage _mealPlanStorage;
|
||||
|
||||
public MealPlanLogic(ILogger<MealPlanLogic> logger, IMealPlanStorage mealPlanStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_mealPlanStorage = mealPlanStorage;
|
||||
}
|
||||
public bool Create(MealPlanBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CheckModel(model);
|
||||
|
||||
if (_mealPlanStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(MealPlanBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_mealPlanStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public MealPlanViewModel? ReadElement(MealPlanSearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. MealPlanName:{MealPlanName}.Id:{Id}", model.MealPlanName, model.Id);
|
||||
|
||||
var element = _mealPlanStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<MealPlanViewModel>? ReadList(MealPlanSearchModel? model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_logger.LogInformation("ReadList. MealPlanName:{MealPlanName}.Id:{ Id}", model?.MealPlanName, model?.Id);
|
||||
|
||||
var list = model == null ? _mealPlanStorage.GetFullList() : _mealPlanStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(MealPlanBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CheckModel(model);
|
||||
|
||||
if (_mealPlanStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(MealPlanBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.MealPlanName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия плана питания", nameof(model.MealPlanName));
|
||||
}
|
||||
|
||||
if (model.MealPlanPrice<0)
|
||||
{
|
||||
throw new ArgumentNullException("Стоимость плана питания не может быть меньше 0", nameof(model.MealPlanPrice));
|
||||
}
|
||||
|
||||
_logger.LogInformation("MealPlan. MealPlanName:{MealPlanName}.MealPlanPrice:{ MealPlanPrice}. Id: { Id}", model.MealPlanName, model.MealPlanPrice, model.Id);
|
||||
|
||||
var element = _mealPlanStorage.GetElement(new MealPlanSearchModel
|
||||
{
|
||||
MealPlanName = model.MealPlanName
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("План питания с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,6 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="OfficePackage\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
@ -18,4 +14,8 @@
|
||||
<ProjectReference Include="..\HotelContracts\HotelContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="OfficePackage\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user