Final version
This commit is contained in:
parent
f15adb2824
commit
d7b655cdad
@ -0,0 +1,89 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.BusinessLogicContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationsContracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceSourceBusinessLogic.BusinessLogic {
|
||||
public class CatergoryWorkLogic : ICategoryWorkLogic {
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICategoryWorkStorage _storage;
|
||||
|
||||
public CatergoryWorkLogic(ILogger logger, ICategoryWorkStorage storage) {
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public bool Create(CategoryWorkBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Insert(model) == null) {
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(CategoryWorkBindingModel model) {
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation($"Delete. Id:{model.Id}");
|
||||
if (_storage.Delete(model) == null) {
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(CategoryWorkBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Update(model) == null) {
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<CategoryWorkViewModel>? ReadList(CategoryWorkSearchModel? model) {
|
||||
_logger.LogInformation($"ReadList. Id:{model?.Id}");
|
||||
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
||||
if (list == null) {
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation($"ReadList. Count:{list.Count}");
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(CategoryWorkBindingModel model, bool withParams = true) {
|
||||
if (model == null) {
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams) {
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.Id).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id категории", nameof(model.Id));
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.ExecutorId).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id исполнителя", nameof(model.ExecutorId));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name)) {
|
||||
throw new ArgumentNullException("Нет названия категории работы", nameof(model.Name));
|
||||
}
|
||||
_logger.LogInformation($"CategoryWork. Id:{model.Id}.Name:{model.Name}");
|
||||
|
||||
var element = _storage.GetElement(new CategoryWorkSearchModel {
|
||||
Name = model.Name
|
||||
});
|
||||
if (element != null && element.Id != model.Id) {
|
||||
throw new InvalidOperationException("Категория с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.BusinessLogicContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationsContracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceSourceBusinessLogic.BusinessLogic {
|
||||
public class ClientLogic : IClientLogic {
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientStorage _storage;
|
||||
|
||||
public ClientLogic(ILogger logger, IClientStorage storage) {
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public bool Create(ClientBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Insert(model) == null) {
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ClientBindingModel model) {
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation($"Delete.Id:{model.Id}");
|
||||
if (_storage.Delete(model) == null) {
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ClientBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Update(model) == null) {
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ClientViewModel? ReadElement(ClientSearchModel model) {
|
||||
if (model == null) {
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation($"ReadElement.Id:{model.Id}.LastName:{model.LastName}");
|
||||
var element = _storage.GetElement(model);
|
||||
if (element == null) {
|
||||
_logger.LogWarning("ReadElement. element not fount");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation($"ReadElement.find.Id:{element.Id}");
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model = null) {
|
||||
_logger.LogInformation($"ReadList.ClientId:{model?.Id}");
|
||||
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
||||
if (list == null) {
|
||||
_logger.LogWarning("ReadList. return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation($"ReadList.Count:{list.Count}");
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void CheckModel(ClientBindingModel model, bool withParams = true) {
|
||||
if (model == null) {
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams) {
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.Id).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id клиента", nameof(model.Id));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.FirstName)) {
|
||||
throw new ArgumentNullException("Нет имени пользователя",nameof(model.FirstName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.LastName)) {
|
||||
throw new ArgumentNullException("Нет фамилии пользователя", nameof(model.LastName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email)) {
|
||||
throw new ArgumentNullException("Нет почты клиента", nameof(model.Email));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password)) {
|
||||
throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber)) {
|
||||
throw new ArgumentNullException("Нет номера телефона пользователя", nameof(model.PhoneNumber));
|
||||
}
|
||||
_logger.LogInformation($"Client. Id:{model.Id}.FirstName:{model.FirstName}.LastName:{model.LastName}." +
|
||||
$"Email:{model.Email}.Password:{model.Password}.PhoneNumber:{model.PhoneNumber}.Login:{model.Login}" +
|
||||
$"Point:{model.Point}");
|
||||
var element = _storage.GetElement(new ClientSearchModel { Email = model.Email });
|
||||
if (element != null && element.Id != model.Id) {
|
||||
throw new InvalidOperationException("Такая почта уже имеется");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.BusinessLogicContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationDataModels;
|
||||
using ServiceStationsContracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceSourceBusinessLogic.BusinessLogic {
|
||||
public class ClientWorkLogic : IClintWorkLogic {
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientWorkStorage _storage;
|
||||
|
||||
public ClientWorkLogic(ILogger<IClintWorkLogic> logger, IClientWorkStorage storage) {
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public bool Create(ClientWorkBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Insert(model) == null) {
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ClientWorkBindingModel model) {
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation($"Delete. ClientID:{model.ClientId}");
|
||||
if (_storage.Delete(model) == null) {
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ClientWorkBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Update(model) == null) {
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<ClientWorkViewModel>? ReadList(ClientWorkSearchModel? model) {
|
||||
_logger.LogInformation($"ReadList. ClientId:{model?.ClientId}.WorkId:{model?.WorkId}");
|
||||
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
||||
if (list == null) {
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation($"ReadList. Count:{list.Count}");
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(ClientWorkBindingModel model, bool withParams = true) {
|
||||
if (model == null) {
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams) {
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.ClientId).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id клиента", nameof(model.ClientId));
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.WorkId).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id работы", nameof(model.WorkId));
|
||||
}
|
||||
_logger.LogInformation($"ClientWork. ClientId:{model.ClientId}.WorkId:{model.WorkId}");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.BusinessLogicContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationsContracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceSourceBusinessLogic.BusinessLogic {
|
||||
public class ExecutorLogic : IExecutorLogic {
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IExecutorStorage _storage;
|
||||
|
||||
public ExecutorLogic(ILogger logger, IExecutorStorage storage) {
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public bool Create(ExecutorBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Insert(model) == null) {
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ExecutorBindingModel model) {
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation($"Delete.Id:{model.Id}");
|
||||
if (_storage.Delete(model) == null) {
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ExecutorBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Update(model) == null) {
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ExecutorViewModel? ReadElement(ExecutorSearchModel model) {
|
||||
if (model == null) {
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation($"ReadElement.Id:{model.Id}.LastName:{model.LastName}");
|
||||
var element = _storage.GetElement(model);
|
||||
if (element == null) {
|
||||
_logger.LogWarning("ReadElement. element not fount");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation($"ReadElement.find.Id:{element.Id}");
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ExecutorViewModel>? ReadList(ExecutorSearchModel? model = null) {
|
||||
_logger.LogInformation($"ReadList.ClientId:{model?.Id}");
|
||||
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
||||
if (list == null) {
|
||||
_logger.LogWarning("ReadList. return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation($"ReadList.Count:{list.Count}");
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(ExecutorBindingModel model, bool withParams = true) {
|
||||
if (model == null) {
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams) {
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.Id).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id исполнителя", nameof(model.Id));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.FirstName)) {
|
||||
throw new ArgumentNullException("Нет имени пользователя", nameof(model.FirstName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.LastName)) {
|
||||
throw new ArgumentNullException("Нет фамилии пользователя", nameof(model.LastName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email)) {
|
||||
throw new ArgumentNullException("Нет почты клиента", nameof(model.Email));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password)) {
|
||||
throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber)) {
|
||||
throw new ArgumentNullException("Нет номера телефона пользователя", nameof(model.PhoneNumber));
|
||||
}
|
||||
_logger.LogInformation($"Client. Id:{model.Id}.FirstName:{model.FirstName}.LastName:{model.LastName}." +
|
||||
$"Email:{model.Email}.Password:{model.Password}.PhoneNumber:{model.PhoneNumber}.Login:{model.Login}");
|
||||
var element = _storage.GetElement(new ExecutorSearchModel { Email = model.Email });
|
||||
if (element != null && element.Id != model.Id) {
|
||||
throw new InvalidOperationException("Такая почта уже имеется");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.BusinessLogicContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationsContracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceSourceBusinessLogic.BusinessLogic {
|
||||
public class ReportLogic : IReportLogic {
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportStorage _storage;
|
||||
|
||||
public ReportLogic(ILogger logger, IReportStorage storage) {
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public bool Create(ReportBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Insert(model) == null) {
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ReportBindingModel model) {
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation($"Delete. Id:{model.Id}");
|
||||
if (_storage.Delete(model) == null) {
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ReportBindingModel model) {
|
||||
CheckModel(model);
|
||||
if (_storage.Update(model) == null) {
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<ReportViewModel>? ReadList(ReportSearchModel model) {
|
||||
_logger.LogInformation($"ReadList. Id:{model?.Id}");
|
||||
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
||||
if (list == null) {
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation($"ReadList. Count:{list.Count}");
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(ReportBindingModel model, bool withParams = true) {
|
||||
if (model == null) {
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams) {
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.Id).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id отчета", nameof(model.Id));
|
||||
}
|
||||
if (model.Count == 0) {
|
||||
throw new ArgumentNullException("Нет отчетов", nameof(model.Id));
|
||||
}
|
||||
_logger.LogInformation($"Report. Id:{model.Id}.Count:{model.Count}");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.BusinessLogicContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationsContracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceSourceBusinessLogic.BusinessLogic {
|
||||
public class ReportWork : IReportWorkLogic {
|
||||
|
||||
private readonly IWorkStorage _storage;
|
||||
|
||||
public ReportWork(IWorkStorage storage) {
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public List<ReportWorkViewModel> GetWorks(ReportWorkBindingModel model) {
|
||||
return _storage.GetFilteredList(new WorkSearchModel {
|
||||
Date = model.Date
|
||||
}).Select(x => new ReportWorkViewModel {
|
||||
Id = x.Id,
|
||||
Date = x.Date,
|
||||
price = x.Price,
|
||||
WorkStatus = x.Status.ToString(),
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.BusinessLogicContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationDataModels;
|
||||
using ServiceStationsContracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceSourceBusinessLogic.BusinessLogic {
|
||||
public class WorkLogic : IWorkLogic {
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkStorage _storage;
|
||||
|
||||
private WorkLogic(ILogger logger, IWorkStorage storage) {
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public bool Create(WorkBindingModel model) {
|
||||
CheckModel(model);
|
||||
model.Status = WorkStatus.Принят;
|
||||
if (_storage.Insert(model) == null) {
|
||||
_logger.LogInformation("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool FinishWork(WorkBindingModel model) {
|
||||
return StatusUpdate(model, WorkStatus.Готов);
|
||||
}
|
||||
|
||||
public bool IssuedWork(WorkBindingModel model) {
|
||||
return StatusUpdate(model, WorkStatus.Выдан);
|
||||
}
|
||||
|
||||
public bool TakeWorkInWork(WorkBindingModel model) {
|
||||
return StatusUpdate(model, WorkStatus.Выполняется);
|
||||
}
|
||||
|
||||
public List<WorkViewModel>? ReadList(WorkSearchModel? model = null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void CheckModel(WorkBindingModel model, bool withParams = true) {
|
||||
if (model == null) {
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams) {
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.Id).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id работы", nameof(model.Id));
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.ExecutorId).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id исполнителя", nameof(model.ExecutorId));
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.ReportId).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id работы", nameof(model.ReportId));
|
||||
}
|
||||
if (string.IsNullOrEmpty((model.CategoryWorkId).ToString())) {
|
||||
throw new ArgumentNullException("Нет Id категории работы", nameof(model.CategoryWorkId));
|
||||
}
|
||||
if (model.Price <= 0) {
|
||||
throw new ArgumentNullException("Цена за работу должна быть больше 0", nameof(model.Price));
|
||||
}
|
||||
_logger.LogInformation($"Work. Id:{model.Id}.Price.{model.Price}.Status:{model.Status}.ExecutorId:{model.ExecutorId}" +
|
||||
$"ReportId:{model.ReportId}.CategoryWordId:{model.CategoryWorkId}");
|
||||
}
|
||||
private bool StatusUpdate(WorkBindingModel model, WorkStatus newOrderStatus) {
|
||||
CheckModel(model, false);
|
||||
var viewModel = _storage.GetElement(new WorkSearchModel { Id = model.Id });
|
||||
if (viewModel == null) {
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (viewModel.Status + 1 != newOrderStatus) {
|
||||
_logger.LogWarning("Status update to " + newOrderStatus.ToString() + " operation failed.");
|
||||
return false;
|
||||
}
|
||||
model.Status = newOrderStatus;
|
||||
if (_storage.Update(model) == null) {
|
||||
_logger.LogWarning("Update operarion failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ServiceStationContracts\ServiceStationContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceSourceRestAPI", "Ser
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceSourceExecutorApp", "ServiceSourceClientApp\ServiceSourceExecutorApp.csproj", "{809ECE9C-4CB6-4F44-BEFE-49ABC38151D2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceSourceBusinessLogic", "ServiceSourceBusinessLogic\ServiceSourceBusinessLogic.csproj", "{A114772E-80AB-43A2-9D00-AB19F309F6ED}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -39,6 +41,10 @@ Global
|
||||
{809ECE9C-4CB6-4F44-BEFE-49ABC38151D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{809ECE9C-4CB6-4F44-BEFE-49ABC38151D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{809ECE9C-4CB6-4F44-BEFE-49ABC38151D2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A114772E-80AB-43A2-9D00-AB19F309F6ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A114772E-80AB-43A2-9D00-AB19F309F6ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A114772E-80AB-43A2-9D00-AB19F309F6ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A114772E-80AB-43A2-9D00-AB19F309F6ED}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -18,7 +18,7 @@ namespace ServiceStationContracts.BindingModels
|
||||
|
||||
public string Login { get; set; } = string.Empty;
|
||||
|
||||
public int? Point { get; set; }
|
||||
public int Point { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceStationContracts.BindingModels {
|
||||
public class ReportWorkBindingModel {
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ namespace ServiceStationContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
ReportViewModel? ReadList(ReportSearchModel model);
|
||||
List<ReportViewModel>? ReadList(ReportSearchModel model);
|
||||
bool Create(ReportBindingModel model);
|
||||
bool Update(ReportBindingModel model);
|
||||
bool Delete(ReportBindingModel model);
|
||||
|
@ -0,0 +1,14 @@
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceStationContracts.BusinessLogicContracts {
|
||||
public interface IReportWorkLogic {
|
||||
// Получение списка заказов за определенный период
|
||||
List<ReportWorkViewModel> GetWorks(ReportWorkBindingModel model);
|
||||
}
|
||||
}
|
@ -8,7 +8,9 @@ namespace ServiceStationContracts.BusinessLogicContracts
|
||||
{
|
||||
List<WorkViewModel>? ReadList(WorkSearchModel? model = null);
|
||||
bool Create(WorkBindingModel model);
|
||||
bool Update(WorkBindingModel model);
|
||||
bool Delete(WorkBindingModel model);
|
||||
|
||||
bool TakeWorkInWork(WorkBindingModel model);
|
||||
bool FinishWork(WorkBindingModel model);
|
||||
bool IssuedWork(WorkBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace ServiceStationContracts.ViewModels
|
||||
[DisplayName("Логин")]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
[DisplayName("Бонусы")]
|
||||
public int? Point { get; set; }
|
||||
public int Point { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceStationContracts.ViewModels {
|
||||
public class ReportWorkViewModel {
|
||||
public int Id { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public double price { get; set; }
|
||||
|
||||
public string WorkStatus { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -10,6 +10,6 @@ namespace ServiceStationDataModels
|
||||
string Password { get; }
|
||||
string PhoneNumber { get; }
|
||||
string Login { get; }
|
||||
int? Point { get; }
|
||||
int Point { get; }
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace ServiceStationsDataBaseImplement.Models
|
||||
[Required]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int? Point { get; set; }
|
||||
public int Point { get; set; }
|
||||
public int Id { get; set; }
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
{
|
||||
@ -77,6 +77,7 @@ namespace ServiceStationsDataBaseImplement.Models
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
|
||||
FirstName = FirstName,
|
||||
LastName = LastName,
|
||||
Email = Email,
|
||||
@ -86,5 +87,7 @@ namespace ServiceStationsDataBaseImplement.Models
|
||||
Point = Point,
|
||||
Id = Id
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user