добила
This commit is contained in:
parent
8bbcbf608e
commit
194747f238
@ -25,6 +25,7 @@ namespace BeautySalon
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["PhoneNumber"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
|
@ -9,13 +9,17 @@ namespace BeautySalon
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IServiceLogic _logicS;
|
||||
private readonly IClientLogic _logicC;
|
||||
private readonly IMasterLogic _logicM;
|
||||
private readonly IVisitLogic _logicV;
|
||||
public FormCreateVisit(ILogger<FormCreateVisit> logger, IVisitLogic logicV, IServiceLogic logicS)
|
||||
public FormCreateVisit(ILogger<FormCreateVisit> logger, IVisitLogic logicV, IServiceLogic logicS, IClientLogic logicC, IMasterLogic logicM)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicS = logicS;
|
||||
_logicV = logicV;
|
||||
_logicC = logicC;
|
||||
_logicM = logicM;
|
||||
LoadData();
|
||||
}
|
||||
|
||||
@ -27,7 +31,41 @@ namespace BeautySalon
|
||||
var list = _logicS.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxMaster.DisplayMember = "ServiceName";
|
||||
comboBoxService.DisplayMember = "ServiceName";
|
||||
comboBoxService.ValueMember = "Id";
|
||||
comboBoxService.DataSource = list;
|
||||
comboBoxService.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка услуг");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
_logger.LogInformation("Загрузка клиентов для заказа");
|
||||
try
|
||||
{
|
||||
var list = _logicC.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxClient.DisplayMember = "ClientFIO";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
comboBoxClient.DataSource = list;
|
||||
comboBoxClient.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка клиентов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
_logger.LogInformation("Загрузка мастеров для заказа");
|
||||
try
|
||||
{
|
||||
var list = _logicM.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxMaster.DisplayMember = "MasterFIO";
|
||||
comboBoxMaster.ValueMember = "Id";
|
||||
comboBoxMaster.DataSource = list;
|
||||
comboBoxMaster.SelectedItem = null;
|
||||
@ -35,7 +73,7 @@ namespace BeautySalon
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка услуг");
|
||||
_logger.LogError(ex, "Ошибка загрузки списка мастеров");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@ -70,12 +108,10 @@ namespace BeautySalon
|
||||
|
||||
private void ComboBoxClient_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void ComboBoxMaster_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void ComboBoxService_SelectedIndexChanged(object sender, EventArgs e)
|
||||
|
82
BeautySalon/FormMaster.Designer.cs
generated
82
BeautySalon/FormMaster.Designer.cs
generated
@ -35,14 +35,14 @@
|
||||
this.buttonDel = new System.Windows.Forms.Button();
|
||||
this.buttonUpd = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.labelWorkingHours = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.textBoxWorkingHours = new System.Windows.Forms.TextBox();
|
||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.NameService = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Time = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.labelWage = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.textBoxWage = new System.Windows.Forms.TextBox();
|
||||
this.groupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -58,7 +58,7 @@
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(123, 24);
|
||||
this.textBoxName.Location = new System.Drawing.Point(138, 24);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(301, 23);
|
||||
this.textBoxName.TabIndex = 1;
|
||||
@ -122,6 +122,24 @@
|
||||
this.dataGridView.Size = new System.Drawing.Size(398, 270);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
this.ID.HeaderText = "ID";
|
||||
this.ID.Name = "ID";
|
||||
this.ID.Visible = false;
|
||||
//
|
||||
// NameService
|
||||
//
|
||||
this.NameService.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.NameService.HeaderText = "Услуга";
|
||||
this.NameService.Name = "NameService";
|
||||
//
|
||||
// Time
|
||||
//
|
||||
this.Time.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Time.HeaderText = "Время на услугу, час(ов)";
|
||||
this.Time.Name = "Time";
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(438, 36);
|
||||
@ -132,14 +150,14 @@
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// labelWorkingHours
|
||||
// labelWage
|
||||
//
|
||||
this.labelWorkingHours.AutoSize = true;
|
||||
this.labelWorkingHours.Location = new System.Drawing.Point(24, 59);
|
||||
this.labelWorkingHours.Name = "labelWorkingHours";
|
||||
this.labelWorkingHours.Size = new System.Drawing.Size(93, 15);
|
||||
this.labelWorkingHours.TabIndex = 3;
|
||||
this.labelWorkingHours.Text = "Рабочее время:";
|
||||
this.labelWage.AutoSize = true;
|
||||
this.labelWage.Location = new System.Drawing.Point(24, 59);
|
||||
this.labelWage.Name = "labelWage";
|
||||
this.labelWage.Size = new System.Drawing.Size(108, 15);
|
||||
this.labelWage.TabIndex = 3;
|
||||
this.labelWage.Text = "Заработная плата:";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
@ -161,41 +179,23 @@
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// textBoxWorkingHours
|
||||
// textBoxWage
|
||||
//
|
||||
this.textBoxWorkingHours.Location = new System.Drawing.Point(123, 53);
|
||||
this.textBoxWorkingHours.Name = "textBoxWorkingHours";
|
||||
this.textBoxWorkingHours.ReadOnly = true;
|
||||
this.textBoxWorkingHours.Size = new System.Drawing.Size(152, 23);
|
||||
this.textBoxWorkingHours.TabIndex = 7;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
this.ID.HeaderText = "ID";
|
||||
this.ID.Name = "ID";
|
||||
this.ID.Visible = false;
|
||||
//
|
||||
// NameService
|
||||
//
|
||||
this.NameService.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.NameService.HeaderText = "Услуга";
|
||||
this.NameService.Name = "NameService";
|
||||
//
|
||||
// Time
|
||||
//
|
||||
this.Time.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Time.HeaderText = "Время на услугу, час(ов)";
|
||||
this.Time.Name = "Time";
|
||||
this.textBoxWage.Location = new System.Drawing.Point(138, 56);
|
||||
this.textBoxWage.Name = "textBoxWage";
|
||||
this.textBoxWage.ReadOnly = true;
|
||||
this.textBoxWage.Size = new System.Drawing.Size(152, 23);
|
||||
this.textBoxWage.TabIndex = 7;
|
||||
//
|
||||
// FormMaster
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(575, 444);
|
||||
this.Controls.Add(this.textBoxWorkingHours);
|
||||
this.Controls.Add(this.textBoxWage);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.labelWorkingHours);
|
||||
this.Controls.Add(this.labelWage);
|
||||
this.Controls.Add(this.groupBox);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelName);
|
||||
@ -218,12 +218,12 @@
|
||||
private Button buttonUpd;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonAdd;
|
||||
private Label labelWorkingHours;
|
||||
private Label labelWage;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private DataGridViewTextBoxColumn ID;
|
||||
private DataGridViewTextBoxColumn NameService;
|
||||
private DataGridViewTextBoxColumn Time;
|
||||
private TextBox textBoxWorkingHours;
|
||||
private TextBox textBoxWage;
|
||||
}
|
||||
}
|
@ -11,14 +11,14 @@ namespace BeautySalon
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMasterLogic _logic;
|
||||
private int? _id;
|
||||
private Dictionary<int, (IServiceModel, int)> _masterServices;
|
||||
private Dictionary<int, (IServiceModel, double)> _masterServices;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormMaster(ILogger<FormMaster> logger, IMasterLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_masterServices = new Dictionary<int, (IServiceModel, int)>();
|
||||
_masterServices = new Dictionary<int, (IServiceModel, double)>();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
@ -33,7 +33,7 @@ namespace BeautySalon
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { ec.Key, ec.Value.Item1.ServiceName, ec.Value.Item2 });
|
||||
}
|
||||
textBoxWorkingHours.Text = CalcWorkingHours().ToString();
|
||||
textBoxWage.Text = CalcWage().ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -129,7 +129,7 @@ namespace BeautySalon
|
||||
MessageBox.Show("Заполните услуги", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxWorkingHours.Text))
|
||||
if (string.IsNullOrEmpty(textBoxWage.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните рабочее время", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
@ -141,7 +141,7 @@ namespace BeautySalon
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
MasterFIO = textBoxName.Text,
|
||||
WorkingHours = Convert.ToDouble(textBoxWorkingHours.Text),
|
||||
Wage = Convert.ToDouble(textBoxWage.Text),
|
||||
MasterServices = _masterServices
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
@ -177,8 +177,8 @@ namespace BeautySalon
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.MasterFIO;
|
||||
textBoxWorkingHours.Text = view.WorkingHours.ToString();
|
||||
_masterServices = view.MasterServices ?? new Dictionary<int, (IServiceModel, int)>();
|
||||
textBoxWage.Text = view.Wage.ToString();
|
||||
_masterServices = view.MasterServices ?? new Dictionary<int, (IServiceModel, double)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
@ -189,14 +189,14 @@ namespace BeautySalon
|
||||
}
|
||||
}
|
||||
}
|
||||
private double CalcWorkingHours()
|
||||
private double CalcWage()
|
||||
{
|
||||
double workingHours = 0;
|
||||
double price = 0;
|
||||
foreach (var elem in _masterServices)
|
||||
{
|
||||
workingHours += elem.Value.Item1?.Cost ?? 0;
|
||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||
}
|
||||
return Math.Round(workingHours, 2);
|
||||
return Math.Round(price * 1.1, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
BeautySalon/FormMasterService.Designer.cs
generated
12
BeautySalon/FormMasterService.Designer.cs
generated
@ -48,7 +48,7 @@
|
||||
// labelTime
|
||||
//
|
||||
this.labelTime.AutoSize = true;
|
||||
this.labelTime.Location = new System.Drawing.Point(23, 60);
|
||||
this.labelTime.Location = new System.Drawing.Point(23, 51);
|
||||
this.labelTime.Name = "labelTime";
|
||||
this.labelTime.Size = new System.Drawing.Size(45, 15);
|
||||
this.labelTime.TabIndex = 1;
|
||||
@ -58,21 +58,21 @@
|
||||
//
|
||||
this.comboBoxService.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxService.FormattingEnabled = true;
|
||||
this.comboBoxService.Location = new System.Drawing.Point(119, 19);
|
||||
this.comboBoxService.Location = new System.Drawing.Point(76, 19);
|
||||
this.comboBoxService.Name = "comboBoxService";
|
||||
this.comboBoxService.Size = new System.Drawing.Size(248, 23);
|
||||
this.comboBoxService.TabIndex = 2;
|
||||
//
|
||||
// textBoxTime
|
||||
//
|
||||
this.textBoxTime.Location = new System.Drawing.Point(119, 57);
|
||||
this.textBoxTime.Location = new System.Drawing.Point(76, 48);
|
||||
this.textBoxTime.Name = "textBoxTime";
|
||||
this.textBoxTime.Size = new System.Drawing.Size(248, 23);
|
||||
this.textBoxTime.TabIndex = 3;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(198, 97);
|
||||
this.buttonSave.Location = new System.Drawing.Point(168, 82);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSave.TabIndex = 4;
|
||||
@ -82,7 +82,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(279, 97);
|
||||
this.buttonCancel.Location = new System.Drawing.Point(249, 82);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
@ -94,7 +94,7 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(379, 132);
|
||||
this.ClientSize = new System.Drawing.Size(347, 117);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.textBoxTime);
|
||||
|
@ -36,9 +36,9 @@ namespace BeautySalon
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public int Time
|
||||
public double Time
|
||||
{
|
||||
get { return Convert.ToInt32(textBoxTime.Text); }
|
||||
get { return Convert.ToDouble(textBoxTime.Text); }
|
||||
set
|
||||
{ textBoxTime.Text = value.ToString(); }
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ namespace BeautySalon
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ServiceName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Cost"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка услуг");
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ namespace BeautySalonBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО мастера", nameof(model.MasterFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Specialization))
|
||||
if (model.Wage <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Нет специализации мастера", nameof(model.MasterFIO));
|
||||
throw new ArgumentNullException("Зарплата должна быть больше 0", nameof(model.Wage));
|
||||
}
|
||||
_logger.LogInformation("Master. MasterFIO:{MasterFIO}. Specialization:{ Specialization}. Id: { Id} ", model.MasterFIO, model.Specialization, model.Id);
|
||||
_logger.LogInformation("Master. MasterFIO:{MasterFIO}. Wage:{ Wage}. Id: { Id} ", model.MasterFIO, model.Wage, model.Id);
|
||||
var element = _masterStorage.GetElement(new MasterSearchModel
|
||||
{
|
||||
MasterFIO = model.MasterFIO
|
||||
|
@ -3,7 +3,7 @@
|
||||
public interface IMasterModel : IId
|
||||
{
|
||||
string MasterFIO { get; }
|
||||
double WorkingHours { get; }
|
||||
public Dictionary<int, (IServiceModel, int)> MasterServices { get; }
|
||||
double Wage { get; }
|
||||
public Dictionary<int, (IServiceModel, double)> MasterServices { get; }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,11 @@ namespace BeautySalonDatabaseImplement.Implements
|
||||
public VisitViewModel? Delete(VisitBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var element = context.Visits.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Visits
|
||||
.Include(x => x.Master)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Service)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Visits.Remove(element);
|
||||
@ -39,13 +43,21 @@ namespace BeautySalonDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Visits.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
return context.Visits
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<VisitViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Visits.Select(x => x.GetViewModel).ToList();
|
||||
return context.Visits
|
||||
.Include(x => x.Service)
|
||||
.Include(x => x.Master)
|
||||
.Include(x => x.Client)
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public VisitViewModel? Insert(VisitBindingModel model)
|
||||
@ -58,7 +70,12 @@ namespace BeautySalonDatabaseImplement.Implements
|
||||
using var context = new BeautySalonDatabase();
|
||||
context.Visits.Add(newVisit);
|
||||
context.SaveChanges();
|
||||
return newVisit.GetViewModel;
|
||||
return context.Visits
|
||||
.Include(x => x.Service)
|
||||
.Include(x => x.Master)
|
||||
.Include(x => x.Client)
|
||||
.FirstOrDefault(x => x.Id == newVisit.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public VisitViewModel? Update(VisitBindingModel model)
|
||||
|
224
BeautySalonDatabaseImplement/Migrations/20230513191649_InitialCreate.Designer.cs
generated
Normal file
224
BeautySalonDatabaseImplement/Migrations/20230513191649_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,224 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
[Migration("20230513191649_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Master", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MasterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Wage")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Masters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MasterService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MasterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Wage")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MasterId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("MasterServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Time")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateOfVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("MasterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MasterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("MasterId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MasterService", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Master", "Master")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("MasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany("MasterServices")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Master");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Master", "Master")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("MasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Master");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Master", b =>
|
||||
{
|
||||
b.Navigation("Services");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("MasterServices");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Masters",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MasterFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Wage = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Masters", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Cost = table.Column<double>(type: "float", nullable: false),
|
||||
Time = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Services", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MasterServices",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MasterId = table.Column<int>(type: "int", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
Wage = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MasterServices", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_MasterServices_Masters_MasterId",
|
||||
column: x => x.MasterId,
|
||||
principalTable: "Masters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_MasterServices_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Visits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DateOfVisit = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
MasterId = table.Column<int>(type: "int", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
MasterFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ServiceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Visits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Masters_MasterId",
|
||||
column: x => x.MasterId,
|
||||
principalTable: "Masters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MasterServices_MasterId",
|
||||
table: "MasterServices",
|
||||
column: "MasterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MasterServices_ServiceId",
|
||||
table: "MasterServices",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_ClientId",
|
||||
table: "Visits",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_MasterId",
|
||||
table: "Visits",
|
||||
column: "MasterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_ServiceId",
|
||||
table: "Visits",
|
||||
column: "ServiceId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "MasterServices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Visits");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Masters");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Services");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,221 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
partial class BeautySalonDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Master", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MasterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Wage")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Masters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MasterService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MasterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Wage")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MasterId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("MasterServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Time")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateOfVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("MasterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MasterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("MasterId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MasterService", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Master", "Master")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("MasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany("MasterServices")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Master");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Master", "Master")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("MasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Master");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Master", b =>
|
||||
{
|
||||
b.Navigation("Services");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("MasterServices");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -12,18 +12,18 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
[Required]
|
||||
public string MasterFIO { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double WorkingHours { get; set; }
|
||||
private Dictionary<int, (IServiceModel, int)>? _masterServices = null;
|
||||
public double Wage { get; set; }
|
||||
private Dictionary<int, (IServiceModel, double)>? _masterServices = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IServiceModel, int)> MasterServices
|
||||
public Dictionary<int, (IServiceModel, double)> MasterServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_masterServices == null)
|
||||
{
|
||||
_masterServices = Services
|
||||
.ToDictionary(recPC => recPC.MasterId, recPC =>
|
||||
(recPC.Service as IServiceModel, recPC.Count));
|
||||
.ToDictionary(recPC => recPC.ServiceId, recPC =>
|
||||
(recPC.Service as IServiceModel, recPC.Wage));
|
||||
}
|
||||
return _masterServices;
|
||||
}
|
||||
@ -38,26 +38,33 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
MasterFIO = model.MasterFIO,
|
||||
WorkingHours = model.WorkingHours,
|
||||
Wage = model.Wage,
|
||||
Services = model.MasterServices.Select(x => new MasterService
|
||||
{
|
||||
Service = context.Services.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
Wage = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(MasterBindingModel model)
|
||||
{
|
||||
MasterFIO = model.MasterFIO;
|
||||
WorkingHours = model.WorkingHours;
|
||||
Wage = model.Wage;
|
||||
}
|
||||
public MasterViewModel GetViewModel => new()
|
||||
public MasterViewModel GetViewModel
|
||||
{
|
||||
Id = Id,
|
||||
MasterFIO = MasterFIO,
|
||||
WorkingHours = WorkingHours,
|
||||
MasterServices = MasterServices
|
||||
};
|
||||
get
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return new MasterViewModel
|
||||
{
|
||||
Id = Id,
|
||||
MasterFIO = MasterFIO,
|
||||
Wage = Wage,
|
||||
MasterServices = MasterServices
|
||||
};
|
||||
}
|
||||
}
|
||||
public void UpdateServices(BeautySalonDatabase context, MasterBindingModel model)
|
||||
{
|
||||
var masterServices = context.MasterServices.Where(rec => rec.MasterId == model.Id).ToList();
|
||||
@ -69,8 +76,7 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateService in masterServices)
|
||||
{
|
||||
updateService.Count =
|
||||
model.MasterServices[updateService.ServiceId].Item2;
|
||||
updateService.Wage = model.MasterServices[updateService.ServiceId].Item2;
|
||||
model.MasterServices.Remove(updateService.ServiceId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
@ -82,7 +88,7 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
Master = master,
|
||||
Service = context.Services.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
Wage = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
[Required]
|
||||
public int ServiceId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public double Wage { get; set; }
|
||||
public virtual Service Service { get; set; } = new();
|
||||
public virtual Master Master { get; set; } = new();
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
public string ServiceName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[Required]
|
||||
public double Time { get; set; }
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<MasterService> MasterServices { get; set; } = new();
|
||||
public static Service? Create(ServiceBindingModel model)
|
||||
|
@ -10,7 +10,6 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public DateTime DateOfVisit { get; private set; }
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public int MasterId { get; private set; }
|
||||
public int ServiceId { get; private set; }
|
||||
@ -19,7 +18,7 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
public virtual Client Client { get; set; }
|
||||
public Client Client { get; set; }
|
||||
public virtual Master Master { get; set; }
|
||||
public virtual Service Service { get; set; }
|
||||
|
||||
@ -50,28 +49,29 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClientId = model.ClientId;
|
||||
ClientFIO = model.ClientFIO;
|
||||
MasterId = model.MasterId;
|
||||
MasterFIO = model.MasterFIO;
|
||||
ServiceId = model.ServiceId;
|
||||
ServiceName = model.ServiceName;
|
||||
|
||||
Sum = model.Sum;
|
||||
DateOfVisit = model.DateOfVisit;
|
||||
}
|
||||
|
||||
public VisitViewModel GetViewModel => new()
|
||||
public VisitViewModel GetViewModel
|
||||
{
|
||||
Id = Id,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = ClientFIO,
|
||||
MasterId = MasterId,
|
||||
MasterFIO = MasterFIO,
|
||||
ServiceId = ServiceId,
|
||||
ServiceName = ServiceName,
|
||||
Sum = Sum,
|
||||
DateOfVisit = DateOfVisit
|
||||
};
|
||||
get
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return new VisitViewModel
|
||||
{
|
||||
Id = Id,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
|
||||
MasterId = MasterId,
|
||||
MasterFIO = context.Masters.FirstOrDefault(x => x.Id == MasterId)?.MasterFIO ?? string.Empty,
|
||||
ServiceId = ServiceId,
|
||||
ServiceName = context.Services.FirstOrDefault(x => x.Id == ServiceId)?.ServiceName ?? string.Empty,
|
||||
Sum = Sum,
|
||||
DateOfVisit = DateOfVisit
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string MasterFIO { get; set; } = string.Empty;
|
||||
public double WorkingHours { get; set; }
|
||||
public Dictionary<int, (IServiceModel, int)> MasterServices { get; set; } = new();
|
||||
public double Wage { get; set; }
|
||||
public Dictionary<int, (IServiceModel, double)> MasterServices { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -3,5 +3,6 @@
|
||||
public class VisitSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ namespace BeautySalonContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
[DisplayName("ФИО мастера")]
|
||||
public string MasterFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Рабочее время")]
|
||||
public double WorkingHours { get; set; }
|
||||
public Dictionary<int, (IServiceModel, int)> MasterServices { get; set; } = new();
|
||||
[DisplayName("Зарплата")]
|
||||
public double Wage { get; set; }
|
||||
public Dictionary<int, (IServiceModel, double)> MasterServices { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user