fix
This commit is contained in:
commit
95978ac7d3
@ -9,6 +9,6 @@ namespace FurnitureContracts.BindingModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int ManagerId { get; set; }
|
public int ManagerId { get; set; }
|
||||||
public int HeadsetModuleId { get; set; }
|
public int HeadsetModuleId { get; set; }
|
||||||
public Dictionary<int, ISalesSalonsModel> SalesSalonsId { get; set; }
|
public Dictionary<int, ISalesSalonsModel> HeadsetSalesSalons { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ namespace FurnitureContracts.BindingModels
|
|||||||
public string UserName { get; set; } = string.Empty;
|
public string UserName { get; set; } = string.Empty;
|
||||||
public string Login { get; set; } = string.Empty;
|
public string Login { get; set; } = string.Empty;
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
public string Role { get; set; } = string.Empty;
|
public string Role { get; set; } = string.Empty;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@ namespace FurnitureContracts.BindingModels
|
|||||||
public string Status { get; set; } = string.Empty;
|
public string Status { get; set; } = string.Empty;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int ManagerId { get; set; }
|
public int ManagerId { get; set; }
|
||||||
public Dictionary<int, ISalesSalonsModel> SalesSalonsId { get; set; }
|
public Dictionary<int, ISalesSalonsModel> OrdersSalesSalons { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,6 @@ namespace FurnitureContracts.SearchModels
|
|||||||
{
|
{
|
||||||
public string? UserName { get; set; }
|
public string? UserName { get; set; }
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public string? Login { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,9 @@ namespace FurnitureContracts.ViewModel
|
|||||||
[DisplayName("Размер")]
|
[DisplayName("Размер")]
|
||||||
public string Size { get; set; } = string.Empty;
|
public string Size { get; set; } = string.Empty;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public Dictionary<int, IHeadsetModuleModel> HeadsetModuleId { get; }
|
public int HeadsetModuleId { get; set; }
|
||||||
|
public int ManagerId { get; set; }
|
||||||
|
public Dictionary<int, ISalesSalonsModel> HeadsetSalesSalons { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,12 @@ namespace FurnitureContracts.ViewModel
|
|||||||
{
|
{
|
||||||
[DisplayName("Имя пользователя")]
|
[DisplayName("Имя пользователя")]
|
||||||
public string UserName { get; set; } = string.Empty;
|
public string UserName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Логин")]
|
[DisplayName("Логин")]
|
||||||
public string Login { get; set; } = string.Empty;
|
public string Login { get; set; } = string.Empty;
|
||||||
public string Password { get; }
|
public string Password { get; set; } = string.Empty;
|
||||||
public string Role { get; }
|
public string Role { get; set; } = string.Empty;
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ namespace FurnitureContracts.ViewModel
|
|||||||
public string Status { get; set; } = string.Empty;
|
public string Status { get; set; } = string.Empty;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int ManagerId { get; set; }
|
public int ManagerId { get; set; }
|
||||||
public Dictionary<int, ISalesSalonsModel> SalesSalonsId { get; set; }
|
public Dictionary<int, ISalesSalonsModel> OrdersSalesSalons { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Implements\" />
|
<Folder Include="Implements\" />
|
||||||
</ItemGroup>
|
<Folder Include="Models\" />
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FurnitureFactoryDataModels\FurnitureFactoryDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FurnitureContracts\FurnitureContracts.csproj" />
|
<ProjectReference Include="..\FurnitureContracts\FurnitureContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\FurnitureFactoryDataModels\FurnitureFactoryDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,140 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FurnitureFactoryDataModels.Models;
|
||||||
|
using FurnitureContracts.BindingModels;
|
||||||
|
using FurnitureContracts.ViewModel;
|
||||||
|
using FurnitureContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureFactoryDataBaseImplements.Implements
|
||||||
|
{
|
||||||
|
public class HeadsetStorage : IHeadsetStorage
|
||||||
|
{
|
||||||
|
int Cost { get; }
|
||||||
|
string Size { get; }
|
||||||
|
public Dictionary<int, ISalesSalonsModel> HeadsetSalesSalons { get; }
|
||||||
|
int ManagerId { get; }
|
||||||
|
int HeadsetModuleId { get; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public List<HeadsetViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FurnitureDataBase();
|
||||||
|
return context.Headsets
|
||||||
|
.Include(x => x.SalesSalons)
|
||||||
|
.ThenInclude(x => x.SalesSalons)
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HeadsetViewModel> GetFilteredList(HeadsetSearchModel model)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!model.ManagerId.HasValue)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new FurnitureDataBase();
|
||||||
|
//if (model.DateFrom.HasValue && model.DateTo.HasValue && model.StudentId.HasValue)
|
||||||
|
//{
|
||||||
|
// return context.Diys
|
||||||
|
// .Include(x => x.Interests)
|
||||||
|
// .ThenInclude(x => x.Interest)
|
||||||
|
// .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo && x.StudentId == model.StudentId)
|
||||||
|
// .ToList()
|
||||||
|
// .Select(x => x.GetViewModel)
|
||||||
|
// .ToList();
|
||||||
|
//}
|
||||||
|
|
||||||
|
return context.Headsets
|
||||||
|
.Include(x => x.SalesSalons)
|
||||||
|
.ThenInclude(x => x.SalesSalon)
|
||||||
|
.Where(x => x.ManagerId == model.ManagerId)
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeadsetViewModel? GetElement(HeadsetSearchModel model)
|
||||||
|
{
|
||||||
|
if ((string.IsNullOrEmpty(model.Title) && !model.Id.HasValue) || !model.ManagerId.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new FurnitureDataBase();
|
||||||
|
return context.Headsets
|
||||||
|
.Include(x => x.SalesSalons)
|
||||||
|
.ThenInclude(x => x.SalesSalons)
|
||||||
|
.FirstOrDefault(x => ((!string.IsNullOrEmpty(model.Size) && x.Size == model.Size) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id)) && x.ManagertId == model.ManagerId)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeadsetViewModel? Insert(HeadsetBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureDataBase();
|
||||||
|
var newHeadset = Headset.Create(context, model);
|
||||||
|
if (newHeadset == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Headsets.Add(newHeadset);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newHeadset.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeadsetViewModel? Update(HeadsetBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureDataBase();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var headset = context.Headsets.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (headset == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
headset.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
headset.UpdateSalesSalons(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
return headset.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeadsetViewModel? Delete(HeadsetBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureDataBase();
|
||||||
|
var element = context.Headsets
|
||||||
|
.Include(x => x.SalesSalons)
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Headsets.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureFactoryDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Furniture
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,104 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using FurnitureFactoryDataModels.Models;
|
||||||
|
using FurnitureContracts.BindingModels;
|
||||||
|
using FurnitureContracts.ViewModel;
|
||||||
|
using FurnitureContracts.SearchModels;
|
||||||
|
|
||||||
namespace FurnitureFactoryDataBaseImplement.Models
|
namespace FurnitureFactoryDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
internal class Headset
|
public class Headset
|
||||||
{
|
{
|
||||||
|
[Required]
|
||||||
|
public string Size { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int HeadsetModuleId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int Cost { get; set; }
|
||||||
|
[Required]
|
||||||
|
public virtual HeadsetModule HeadsetModule { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ManagerId { get; set; }
|
||||||
|
public virtual Manager Manager { get; set; }
|
||||||
|
private Dictionary<int, ISalesSalonsModel>? _HeadsetSalesSalons = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, ISalesSalonsModel> HeadsetSalesSalons
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_HeadsetSalesSalons == null)
|
||||||
|
{
|
||||||
|
_HeadsetSalesSalons = SalesSalons
|
||||||
|
.ToDictionary(recPC => recPC.SalesSalonsId, recPC => (recPC.SalesSalons as ISalesSalonsModel));
|
||||||
|
}
|
||||||
|
return _HeadsetSalesSalons;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
[ForeignKey("HeadsetId")]
|
||||||
|
public virtual List<HeadsetSalesSalons> SalesSalons { get; set; } = new();
|
||||||
|
public static Headset Create(FurnitureDataBase context, HeadsetBindingModel model)
|
||||||
|
{
|
||||||
|
return new Headset()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Size = model.Size,
|
||||||
|
HeadsetModuleId = model.HeadsetModuleId,
|
||||||
|
ManagerId = model.ManagerId,
|
||||||
|
SalesSalons = model.HeadsetSalesSalons.Select(x => new HeadsetSalesSalons
|
||||||
|
{
|
||||||
|
SalesSalons = context.SalesSalons.First(y => y.Id == x.Key),
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(HeadsetBindingModel model)
|
||||||
|
{
|
||||||
|
Cost = model.Cost;
|
||||||
|
Size = model.Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeadsetViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Size = Size,
|
||||||
|
Cost = Cost,
|
||||||
|
HeadsetModuleId = HeadsetModuleId,
|
||||||
|
ManagerId = ManagerId,
|
||||||
|
HeadsetSalesSalons = HeadsetSalesSalons
|
||||||
|
};
|
||||||
|
|
||||||
|
public void UpdateInterests(FurnitureDataBase context, HeadsetBindingModel model)
|
||||||
|
{
|
||||||
|
var headsetSalesSalons = context.HeadsetSalesSalons.Where(rec => rec.HeadsetId == model.Id).ToList();
|
||||||
|
if (headsetSalesSalons != null && HeadsetSalesSalons.Count > 0)
|
||||||
|
{
|
||||||
|
context.HeadsetSalesSalons.RemoveRange(headsetSalesSalons.Where(rec => !model.HeadsetSalesSalons.ContainsKey(rec.SalesSalonsId)));
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
foreach (var updateSalesSalons in headsetSalesSalons)
|
||||||
|
{
|
||||||
|
model.HeadsetSalesSalons.Remove(updateSalesSalons.SalesSalonsId);
|
||||||
|
}
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
var headset = context.Headsets.First(x => x.Id == Id);
|
||||||
|
foreach (var pc in model.HeadsetSalesSalons)
|
||||||
|
{
|
||||||
|
context.HeadsetSalesSalons.Add(new HeadsetSalesSalons
|
||||||
|
{
|
||||||
|
Headset = headset,
|
||||||
|
SalesSalons = context.SalesSalons.First(x => x.Id == pc.Key),
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_HeadsetSalesSalons = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureFactoryDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class HeadsetModule
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureFactoryDataBaseImplement.Models
|
namespace FurnitureFactoryDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
internal class HeadsetSalesSalons
|
public class HeadsetSalesSalons
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
@ -1,12 +1,70 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using FurnitureFactoryDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using FurnitureContracts.BindingModels;
|
||||||
|
using FurnitureContracts.ViewModel;
|
||||||
|
using FurnitureContracts.SearchModels;
|
||||||
|
|
||||||
namespace FurnitureFactoryDataBaseImplement.Models
|
namespace FurnitureFactoryDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
internal class Manager
|
public class Manager
|
||||||
{
|
{
|
||||||
|
[Required]
|
||||||
|
public string UserName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Role { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Login { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("ManagerId")]
|
||||||
|
public virtual List<SalesSalons> SalesSalons { get; set; } = new();
|
||||||
|
[ForeignKey("ManagerId")]
|
||||||
|
public virtual List<Headset> Headsets { get; set; } = new();
|
||||||
|
[ForeignKey("ManagerId")]
|
||||||
|
public virtual List<Orders> Orders { get; set; } = new();
|
||||||
|
public static Manager Create(FurnitureDataBase context, ManagerBindingModel model)
|
||||||
|
{
|
||||||
|
return new Manager()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
UserName = model.UserName,
|
||||||
|
Role = model.Role,
|
||||||
|
Email = model.Email,
|
||||||
|
Login = model.Login,
|
||||||
|
Password = model.Password,
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ManagerBindingModel model)
|
||||||
|
{
|
||||||
|
UserName = model.UserName;
|
||||||
|
Role = model.Role;
|
||||||
|
Email = model.Email;
|
||||||
|
Login = model.Login;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ManagerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
UserName = UserName,
|
||||||
|
Role = Role,
|
||||||
|
Email = Email,
|
||||||
|
Login = Login,
|
||||||
|
Password = Password
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,124 +1,101 @@
|
|||||||
//using System;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
//using System.Collections.Generic;
|
using System.ComponentModel.DataAnnotations;
|
||||||
//using System.Linq;
|
using System.Linq;
|
||||||
//using System.Text;
|
using System.Text;
|
||||||
//using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
//using FurnitureContracts.BindingModels;
|
using FurnitureFactoryDataModels.Models;
|
||||||
//using FurnitureContracts.ViewModel;
|
using System.ComponentModel;
|
||||||
//using FurnitureFactoryDataModels.Models;
|
using FurnitureContracts.BindingModels;
|
||||||
//using System;
|
using FurnitureContracts.ViewModel;
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.ComponentModel.DataAnnotations;
|
|
||||||
//using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
//namespace FurnitureFactoryDataBaseImplement.Models
|
namespace FurnitureFactoryDataBaseImplement.Models
|
||||||
//{
|
{
|
||||||
// internal class Orders : IOrders
|
public class Orders : IOrdersModel
|
||||||
// {
|
{
|
||||||
// // мое
|
|
||||||
// //DateTime Date { get; }
|
|
||||||
// //string Status { get; }
|
|
||||||
// //public Dictionary<int, IFurnitureModel> FurnitureId { get; }
|
|
||||||
// //int ManagerId { get; }
|
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Status { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ManagerId { get; set; }
|
||||||
|
public virtual Manager Manager { get; set; }
|
||||||
|
|
||||||
|
private Dictionary<int, ISalesSalonsModel>? _OrdersSalesSalons = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, ISalesSalonsModel> OrdersSalesSalons
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_OrdersSalesSalons == null)
|
||||||
|
{
|
||||||
|
_OrdersSalesSalons = SalesSalons
|
||||||
|
.ToDictionary(recPC => recPC.SalesSalonsId, recPC => (recPC.SalesSalons as ISalesSalonsModel));
|
||||||
|
}
|
||||||
|
return _OrdersSalesSalons;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// string Title { get; }
|
public int Id { get; set; }
|
||||||
// string Description { get; }
|
[ForeignKey("OrdersId")]
|
||||||
// string? TaskName { get; }
|
public virtual List <OrdersSalesSalons> SalesSalons { get; set; } = new();
|
||||||
// DateTime DateCreate { get; }
|
[ForeignKey("OrdersId")]
|
||||||
// int TaskId { get; }
|
public virtual List<Furniture> Furniture { get; set; } = new();
|
||||||
// int StudentId { get; }
|
public static Orders Create(FurnitureDataBase context, OrdersBindingModel model)
|
||||||
// string StudentName { get; }
|
{
|
||||||
// Dictionary<int, IInterest> DiyInterests { get; }
|
return new Orders()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Status = model.Status,
|
||||||
|
Date = model.Date,
|
||||||
|
ManagerId = model.ManagerId,
|
||||||
|
SalesSalons = model.OrdersSalesSalons.Select(x => new OrdersSalesSalons
|
||||||
|
{
|
||||||
|
SalesSalons = context.SalesSalons.First(y => y.Id == x.Key),
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(OrdersBindingModel model)
|
||||||
|
{
|
||||||
|
Status = model.Status;
|
||||||
|
Date = model.Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrdersViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Status = Status,
|
||||||
|
Date = Date,
|
||||||
|
ManagerId = ManagerId,
|
||||||
|
OrdersSalesSalons = OrdersSalesSalons
|
||||||
|
};
|
||||||
|
|
||||||
// [Required]
|
public void UpdateInterests(FurnitureDataBase context, OrdersBindingModel model)
|
||||||
// public string Status { get; set; } = string.Empty;
|
{
|
||||||
// [Required]
|
var ordersSalesSalons = context.OrdersSalesSalons.Where(rec => rec.OrdersId == model.Id).ToList();
|
||||||
// public DateTime Date { get; set; }
|
if (ordersSalesSalons != null && OrdersSalesSalons.Count > 0)
|
||||||
// [Required]
|
{
|
||||||
// public int ManagerId { get; set; }
|
context.OrdersSalesSalons.RemoveRange(ordersSalesSalons.Where(rec => !model.OrdersSalesSalons.ContainsKey(rec.SalesSalonsId)));
|
||||||
// public virtual Manager Manager { get; set; }
|
context.SaveChanges();
|
||||||
// private Dictionary<int, IFurnitureModel>? _FurnitureId = null;
|
|
||||||
// [NotMapped]
|
|
||||||
// public Dictionary<int, IFurnitureModel> FurnitureId
|
|
||||||
// {
|
|
||||||
// get
|
|
||||||
// {
|
|
||||||
// if (_FurnitureId == null)
|
|
||||||
// {
|
|
||||||
// _FurnitureId = Furniture
|
|
||||||
// .ToDictionary(recPC => recPC.FurnitureId, recPC => (recPC.Furniture as IFurniture));
|
|
||||||
// }
|
|
||||||
// return _FurnitureId;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public int Id { get; set; }
|
foreach (var updateSalesSalons in ordersSalesSalons)
|
||||||
// [ForeignKey("OrdersId")]
|
{
|
||||||
// public virtual List<DiyInterest> Interests { get; set; } = new();
|
model.OrdersSalesSalons.Remove(updateSalesSalons.SalesSalonsId);
|
||||||
// public static Diy Create(SchoolDataBase context, DiyBindingModel model)
|
}
|
||||||
// {
|
context.SaveChanges();
|
||||||
// return new Diy()
|
}
|
||||||
// {
|
var orders = context.Orders.First(x => x.Id == Id);
|
||||||
// Id = model.Id,
|
foreach (var pc in model.OrdersSalesSalons)
|
||||||
// Title = model.Title,
|
{
|
||||||
// Description = model.Description,
|
context.OrdersSalesSalons.Add(new OrdersSalesSalons
|
||||||
// DateCreate = model.DateCreate,
|
{
|
||||||
// TaskId = model.TaskId,
|
Orders = orders,
|
||||||
// TaskName = model.TaskName,
|
SalesSalons = context.SalesSalons.First(x => x.Id == pc.Key),
|
||||||
// StudentId = model.StudentId,
|
});
|
||||||
// StudentName = model.StudentName,
|
context.SaveChanges();
|
||||||
// Interests = model.DiyInterests.Select(x => new DiyInterest
|
}
|
||||||
// {
|
_OrdersSalesSalons = null;
|
||||||
// Interest = context.Interests.First(y => y.Id == x.Key),
|
}
|
||||||
// }).ToList()
|
}
|
||||||
// };
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Update(OrdersBindingModel model)
|
|
||||||
// {
|
|
||||||
// Status = model.Status;
|
|
||||||
// Date = model.Date;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public OrdersViewModel GetViewModel => new()
|
|
||||||
// {
|
|
||||||
// Id = Id,
|
|
||||||
// Status=Status,
|
|
||||||
// Date = Date,
|
|
||||||
// ManagerId = ManagerId,
|
|
||||||
// FurnitureId = FurnitureId
|
|
||||||
// };
|
|
||||||
|
|
||||||
// public void UpdateInterests(FurnitureDataBase context, OrdersBindingModel model)
|
|
||||||
// {
|
|
||||||
// var diyInterests = context.DiyInterests.Where(rec => rec.DiyId == model.Id).ToList();
|
|
||||||
// if (diyInterests != null && diyInterests.Count > 0)
|
|
||||||
// {
|
|
||||||
// context.DiyInterests.RemoveRange(diyInterests.Where(rec => !model.DiyInterests.ContainsKey(rec.InterestId)));
|
|
||||||
// context.SaveChanges();
|
|
||||||
|
|
||||||
// foreach (var updateInterest in diyInterests)
|
|
||||||
// {
|
|
||||||
// model.DiyInterests.Remove(updateInterest.InterestId);
|
|
||||||
// }
|
|
||||||
// context.SaveChanges();
|
|
||||||
// }
|
|
||||||
// var diy = context.Diys.First(x => x.Id == Id);
|
|
||||||
// foreach (var pc in model.DiyInterests)
|
|
||||||
// {
|
|
||||||
// context.DiyInterests.Add(new DiyInterest
|
|
||||||
// {
|
|
||||||
// Diy = diy,
|
|
||||||
// Interest = context.Interests.First(x => x.Id == pc.Key),
|
|
||||||
// });
|
|
||||||
// context.SaveChanges();
|
|
||||||
// }
|
|
||||||
// _DiyInterests = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FurnitureFactoryDataBaseImplement.Models
|
namespace FurnitureFactoryDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
internal class OrdersSalesSalons
|
public class OrdersSalesSalons
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int OrdersId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int SalesSalonsId { get; set; }
|
||||||
|
public virtual Orders Orders { get; set; } = new();
|
||||||
|
public virtual SalesSalons SalesSalons { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,25 +12,8 @@ using FurnitureContracts.ViewModel;
|
|||||||
|
|
||||||
namespace FurnitureFactoryDataBaseImplement.Models
|
namespace FurnitureFactoryDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
internal class SalesSalons
|
public class SalesSalons
|
||||||
{
|
{
|
||||||
//[DisplayName("Название")]
|
|
||||||
//public string Name { get; set; } = string.Empty;
|
|
||||||
//[DisplayName("Адресс")]
|
|
||||||
//public string Address { get; set; } = string.Empty;
|
|
||||||
//public int Id { get; set; }
|
|
||||||
//public int ManagerId { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//public int StudentId { get; set; }
|
|
||||||
//[DisplayName("Название")]
|
|
||||||
//public string Title { get; set; } = string.Empty;
|
|
||||||
//[DisplayName("Описание")]
|
|
||||||
//public string Description { get; set; } = string.Empty;
|
|
||||||
//[DisplayName("Номер")]
|
|
||||||
//public int Id { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
@ -41,9 +24,9 @@ namespace FurnitureFactoryDataBaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int ManagerId { get; set; }
|
public int ManagerId { get; set; }
|
||||||
public virtual Manager Manager { get; set; }
|
public virtual Manager Manager { get; set; }
|
||||||
[ForeignKey("HeadsetId")]
|
[ForeignKey("SalesSalonsId")]
|
||||||
public virtual List<HeadsetSalesSalons> HeadsetSalesSalons { get; set; } = new();
|
public virtual List<HeadsetSalesSalons> HeadsetSalesSalons { get; set; } = new();
|
||||||
[ForeignKey("OrdersId")]
|
[ForeignKey("SalesSalonsId")]
|
||||||
public virtual List<OrdersSalesSalons> OrdersSalesSalons { get; set; } = new();
|
public virtual List<OrdersSalesSalons> OrdersSalesSalons { get; set; } = new();
|
||||||
|
|
||||||
public static SalesSalons? Create(SalesSalonsBindingModel model)
|
public static SalesSalons? Create(SalesSalonsBindingModel model)
|
||||||
|
@ -10,7 +10,7 @@ namespace FurnitureFactoryDataModels.Models
|
|||||||
{
|
{
|
||||||
int Cost { get;}
|
int Cost { get;}
|
||||||
string Size { get; }
|
string Size { get; }
|
||||||
public Dictionary<int, ISalesSalonsModel> SalesSalonsId { get; }
|
public Dictionary<int, ISalesSalonsModel> HeadsetSalesSalons { get; }
|
||||||
int ManagerId { get; }
|
int ManagerId { get; }
|
||||||
int HeadsetModuleId { get; }
|
int HeadsetModuleId { get; }
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -10,7 +11,7 @@ namespace FurnitureFactoryDataModels.Models
|
|||||||
{
|
{
|
||||||
string Login { get; }
|
string Login { get; }
|
||||||
string Password { get; }
|
string Password { get; }
|
||||||
string Role { get; }
|
string Email { get; }
|
||||||
string UserName { get; }
|
string UserName { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ namespace FurnitureFactoryDataModels.Models
|
|||||||
{
|
{
|
||||||
DateTime Date { get; }
|
DateTime Date { get; }
|
||||||
string Status { get; }
|
string Status { get; }
|
||||||
public Dictionary<int, ISalesSalonsModel> SalesSalonsId { get; }
|
public Dictionary<int, ISalesSalonsModel> OrdersSalesSalons { get; }
|
||||||
int ManagerId { get; }
|
int ManagerId { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user