Compare commits
2 Commits
7830d9c21f
...
a111f8e999
Author | SHA1 | Date | |
---|---|---|---|
a111f8e999 | |||
00e38be80e |
13
Course/Contracts/BindingModels/GuarantorBindingModel.cs
Normal file
13
Course/Contracts/BindingModels/GuarantorBindingModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using DataModels.Models;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class GuarantorBindingModel : IGuarantorModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Login { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,9 +1,4 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
@ -11,8 +6,9 @@ namespace Contracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Country { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Country { get; set; } = string.Empty;
|
||||
public int ProductId { get; set; }
|
||||
public Dictionary<int, (IWorkerModel, int)> MachineWorker { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,16 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class WorkerBindingModel : IWorkerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public DateTime Birthday { get; set; }
|
||||
public string Specialization { get; set; }
|
||||
public string Specialization { get; set; } = string.Empty;
|
||||
public double Salary { get; set; }
|
||||
}
|
||||
public Dictionary<int, IWorkshopModel> WorkerWorkshop { get; set; } = new();
|
||||
public Dictionary<int, IMachineModel> WorkerMachine { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class WorkshopBindingModel : IWorkshopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string Director { get; set; }
|
||||
public Dictionary<int, (IWorkerModel, int)> WorkshopWorker { get; set; } = new();
|
||||
public int UserId { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public string Director { get; set; } = string.Empty;
|
||||
public int ProductionId { get; set; }
|
||||
public Dictionary<int, IWorkerModel> WorkshopWorker { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
15
Course/Contracts/BusinessLogicsContracts/IGuarantorLogic.cs
Normal file
15
Course/Contracts/BusinessLogicsContracts/IGuarantorLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
|
||||
namespace Contracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IGuarantorLogic
|
||||
{
|
||||
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||
ImplementerViewModel? ReadElement(ImplementerSearchModel? model);
|
||||
bool Create(ImplementerBindingModel? model);
|
||||
bool Update(ImplementerBindingModel? model);
|
||||
bool Delete(ImplementerBindingModel? model);
|
||||
}
|
||||
}
|
15
Course/Contracts/BusinessLogicsContracts/IMachineLogic.cs
Normal file
15
Course/Contracts/BusinessLogicsContracts/IMachineLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
|
||||
namespace Contracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IMachineLogic
|
||||
{
|
||||
List<MachineViewModel>? ReadList(MachineSearchModel? model);
|
||||
MachineViewModel? ReadElement(MachineSearchModel? model);
|
||||
bool Create(MachineBindingModel? model);
|
||||
bool Update(MachineBindingModel? model);
|
||||
bool Delete(MachineBindingModel? model);
|
||||
}
|
||||
}
|
15
Course/Contracts/BusinessLogicsContracts/IWorkerLogic.cs
Normal file
15
Course/Contracts/BusinessLogicsContracts/IWorkerLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
|
||||
namespace Contracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWorkerLogic
|
||||
{
|
||||
List<WorkerViewModel>? ReadList(WorkerSearchModel? model);
|
||||
WorkerViewModel? ReadElement(WorkerSearchModel? model);
|
||||
bool Create(WorkerBindingModel? model);
|
||||
bool Update(WorkerBindingModel? model);
|
||||
bool Delete(WorkerBindingModel? model);
|
||||
}
|
||||
}
|
15
Course/Contracts/BusinessLogicsContracts/IWorkshopLogic.cs
Normal file
15
Course/Contracts/BusinessLogicsContracts/IWorkshopLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
|
||||
namespace Contracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWorkshopLogic
|
||||
{
|
||||
List<WorkshopViewModel>? ReadList(WorkshopSearchModel? model);
|
||||
WorkshopViewModel? ReadElement(WorkshopSearchModel? model);
|
||||
bool Create(WorkshopBindingModel? model);
|
||||
bool Update(WorkshopBindingModel? model);
|
||||
bool Delete(WorkshopBindingModel? model);
|
||||
}
|
||||
}
|
8
Course/Contracts/SearchModels/GuarantorSearchModel.cs
Normal file
8
Course/Contracts/SearchModels/GuarantorSearchModel.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class GuarantorSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Login { get; set; }
|
||||
}
|
||||
}
|
9
Course/Contracts/SearchModels/MachineSearchModel.cs
Normal file
9
Course/Contracts/SearchModels/MachineSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class MachineSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
9
Course/Contracts/SearchModels/WorkerSearchModel.cs
Normal file
9
Course/Contracts/SearchModels/WorkerSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class WorkerSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
9
Course/Contracts/SearchModels/WorkshopSearchModel.cs
Normal file
9
Course/Contracts/SearchModels/WorkshopSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class WorkshopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
16
Course/Contracts/StoragesContracts/IGuarantorStorage.cs
Normal file
16
Course/Contracts/StoragesContracts/IGuarantorStorage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
|
||||
namespace Contracts.StoragesContracts
|
||||
{
|
||||
public interface IGuarantorStorage
|
||||
{
|
||||
List<GuarantorViewModel> GetFullList();
|
||||
List<GuarantorViewModel> GetFilteredList(GuarantorSearchModel model);
|
||||
GuarantorViewModel? GetElement(GuarantorSearchModel model);
|
||||
GuarantorViewModel? Insert(GuarantorBindingModel model);
|
||||
GuarantorViewModel? Update(GuarantorBindingModel model);
|
||||
GuarantorViewModel? Delete(GuarantorBindingModel model);
|
||||
}
|
||||
}
|
16
Course/Contracts/StoragesContracts/IMachineStorage.cs
Normal file
16
Course/Contracts/StoragesContracts/IMachineStorage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
|
||||
namespace Contracts.StoragesContracts
|
||||
{
|
||||
public interface IMachineStorage
|
||||
{
|
||||
List<MachineViewModel> GetFullList();
|
||||
List<MachineViewModel> GetFilteredList(MachineSearchModel model);
|
||||
MachineViewModel? GetElement(MachineSearchModel model);
|
||||
MachineViewModel? Insert(MachineBindingModel model);
|
||||
MachineViewModel? Update(MachineBindingModel model);
|
||||
MachineViewModel? Delete(MachineBindingModel model);
|
||||
}
|
||||
}
|
16
Course/Contracts/StoragesContracts/IWorkerStorage.cs
Normal file
16
Course/Contracts/StoragesContracts/IWorkerStorage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
|
||||
namespace Contracts.StoragesContracts
|
||||
{
|
||||
public interface IWorkerStorage
|
||||
{
|
||||
List<WorkerViewModel> GetFullList();
|
||||
List<WorkerViewModel> GetFilteredList(WorkerSearchModel model);
|
||||
WorkerViewModel? GetElement(WorkerSearchModel model);
|
||||
WorkerViewModel? Insert(WorkerBindingModel model);
|
||||
WorkerViewModel? Update(WorkerBindingModel model);
|
||||
WorkerViewModel? Delete(WorkerBindingModel model);
|
||||
}
|
||||
}
|
16
Course/Contracts/StoragesContracts/IWorkshopStorage.cs
Normal file
16
Course/Contracts/StoragesContracts/IWorkshopStorage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
|
||||
namespace Contracts.StoragesContracts
|
||||
{
|
||||
public interface IWorkshopStorage
|
||||
{
|
||||
List<WorkshopViewModel> GetFullList();
|
||||
List<WorkshopViewModel> GetFilteredList(WorkshopSearchModel model);
|
||||
WorkshopViewModel? GetElement(WorkshopSearchModel model);
|
||||
WorkshopViewModel? Insert(WorkshopBindingModel model);
|
||||
WorkshopViewModel? Update(WorkshopBindingModel model);
|
||||
WorkshopViewModel? Delete(WorkshopBindingModel model);
|
||||
}
|
||||
}
|
17
Course/Contracts/ViewModels/GuarantorViewModel.cs
Normal file
17
Course/Contracts/ViewModels/GuarantorViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class GuarantorViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Имя поручителя")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Логин")]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
16
Course/Contracts/ViewModels/MachineViewModel.cs
Normal file
16
Course/Contracts/ViewModels/MachineViewModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using DataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class MachineViewModel : IMachineModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название станка")]
|
||||
public string Title { get; set; } = string.Empty;
|
||||
[DisplayName("Страна производитель")]
|
||||
public string Country { get; set; } = string.Empty;
|
||||
public int UserId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
}
|
||||
}
|
19
Course/Contracts/ViewModels/WorkerViewModel.cs
Normal file
19
Course/Contracts/ViewModels/WorkerViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using DataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class WorkerViewModel : IWorkerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Имя работника")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Дата рождения")]
|
||||
public DateTime Birthday { get; set; }
|
||||
[DisplayName("Специальность")]
|
||||
public string Specialization { get; set; } = string.Empty;
|
||||
[DisplayName("Заработная плата")]
|
||||
public double Salary { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
18
Course/Contracts/ViewModels/WorkshopViewModel.cs
Normal file
18
Course/Contracts/ViewModels/WorkshopViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using DataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class WorkshopViewModel : IWorkshopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название цеха")]
|
||||
public string Title { get; set; } = string.Empty;
|
||||
[DisplayName("Адрес цеха")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
[DisplayName("ФИО директора цеха")]
|
||||
public string Director { get; set; } = string.Empty;
|
||||
public int UserId { get; set; }
|
||||
public int ProductionId { get; set; }
|
||||
}
|
||||
}
|
6
Course/DataModels/Models/IGuarantorModel.cs
Normal file
6
Course/DataModels/Models/IGuarantorModel.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public interface IGuarantorModel : IUserModel
|
||||
{
|
||||
}
|
||||
}
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataModels.Models
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public interface IMachineModel : IId
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataModels.Models
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public interface IWorkerModel : IId
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataModels.Models
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public interface IWorkshopModel : IId
|
||||
{
|
||||
|
@ -15,5 +15,11 @@ namespace DatabaseImplement
|
||||
public virtual DbSet<Production> Productions { get; set; }
|
||||
public virtual DbSet<DetailProduction> DetailProductions { get; set; }
|
||||
public virtual DbSet<Implementer> Implementers { get; set; }
|
||||
public virtual DbSet<Guarantor> Guarantors { get; set; }
|
||||
public virtual DbSet<Machine> Machines { get; set; }
|
||||
public virtual DbSet<WorkerMachine> WorkerMachines { get; set; }
|
||||
public virtual DbSet<Worker> Workers { get; set; }
|
||||
public virtual DbSet<Workshop> Workshops { get; set; }
|
||||
public virtual DbSet<WorkerWorkshop> WorkerWorkshops { get; set; }
|
||||
}
|
||||
}
|
||||
|
71
Course/DatabaseImplement/Models/Machine.cs
Normal file
71
Course/DatabaseImplement/Models/Machine.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.ViewModels;
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace DatabaseImplement.Models
|
||||
{
|
||||
public class Machine : IMachineModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string Title { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Country { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public int UserId { get; private set; }
|
||||
[Required]
|
||||
public int ProductId { get; private set; }
|
||||
public virtual Product Product { get; set; }
|
||||
[ForeignKey("WorkerId")]
|
||||
public virtual List<WorkerMachine> WorkerMachines { get; set; } = new();
|
||||
public static Machine? Create(MachineBindingModel model, FactoryGoWorkDatabase context)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Machine()
|
||||
{
|
||||
Id = model.Id,
|
||||
Title = model.Title,
|
||||
Country = model.Country,
|
||||
ProductId = model.ProductId,
|
||||
Product = context.Products.FirstOrDefault(x => x.Id == model.ProductId)!,
|
||||
UserId = model.UserId
|
||||
};
|
||||
}
|
||||
public static Machine Create(MachineViewModel model)
|
||||
{
|
||||
return new Machine
|
||||
{
|
||||
Id = model.Id,
|
||||
Title = model.Title,
|
||||
Country = model.Country,
|
||||
UserId = model.UserId
|
||||
};
|
||||
}
|
||||
public void Update(MachineBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
return;
|
||||
Title = model.Title;
|
||||
Country = model.Country;
|
||||
}
|
||||
public MachineViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Title = Title,
|
||||
Country = Country,
|
||||
UserId = UserId,
|
||||
ProductId = ProductId
|
||||
};
|
||||
}
|
||||
}
|
22
Course/DatabaseImplement/Models/WorkerMachine.cs
Normal file
22
Course/DatabaseImplement/Models/WorkerMachine.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Models
|
||||
{
|
||||
public class WorkerMachine
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int WorkerId { get; set; }
|
||||
[Required]
|
||||
public int MachineId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Worker Worker { get; set; } = new();
|
||||
public virtual Machine Machine { get; set; } = new();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user