частичная реализация BuildStorage

This commit is contained in:
Николай 2023-04-01 17:04:56 +04:00
parent 61d8d1170b
commit aac6acd899
10 changed files with 161 additions and 6 deletions

View File

@ -1,5 +1,4 @@
using HardwareShopDataModels.Models;
using HardwareShopDataModels.Models;
using System.ComponentModel;
namespace HardwareShopContracts.BindingModels
{

View File

@ -1,5 +1,4 @@
using HardwareShopDataModels.Models;
using HardwareShopDataModels.Models;
using System.ComponentModel;
namespace HardwareShopContracts.BindingModels

View File

@ -1,6 +1,5 @@
using HardwareShopDataModels.Enums;
using HardwareShopDataModels.Models;
using HardwareShopDataModels.Models;
using System.ComponentModel;
namespace HardwareShopContracts.BindingModels
{

View File

@ -7,7 +7,7 @@ namespace HardwareShopContracts.StoragesContracts
public interface IBuildStorage
{
List<BuildViewModel> GetFullList();
List<BuildViewModel> GetFilteredList(BuildSearchModel model);
List<BuildViewModel> GetFilteredList(UserSearchModel model);
BuildViewModel? GetElement(BuildSearchModel model);
BuildViewModel? Insert(BuildBindingModel model);
BuildViewModel? Update(BuildBindingModel model);

View File

@ -21,7 +21,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Implements\" />
<Folder Include="Implements\Storekeeper\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,21 @@
using HardwareShopContracts.BindingModels;
using HardwareShopContracts.SearchModels;
using HardwareShopContracts.ViewModels;
namespace HardwareShopContracts.StoragesContracts
{
public interface IUsertorage
{
List<UserViewModel> GetFullList();
List<UserViewModel> GetFilteredList(UserSearchModel model);
UserViewModel? GetElement(UserSearchModel model);
UserViewModel? Insert(UserBindingModel model);
UserViewModel? Update(UserBindingModel model);
UserViewModel? Delete(UserBindingModel model);
}
}

View File

@ -0,0 +1,60 @@
using HardwareShopContracts.BindingModels;
using HardwareShopContracts.SearchModels;
using HardwareShopContracts.ViewModels;
using HardwareShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
namespace HardwareShopContracts.StoragesContracts
{
public class BuildStorage : IBuildStorage
{
public List<BuildViewModel> GetFullList()
{
using var context = new HardwareShopDatabase();
return context.Builds
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.Include(x => x.Comments)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<BuildViewModel> GetFilteredList(UserSearchModel model)
{
if (model.Id.HasValue)
{
return new();
}
using var context = new HardwareShopDatabase();
return context.Builds
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.Include(x => x.Comments)
.Where(x => x.UserId == model.Id)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public BuildViewModel? GetElement(BuildSearchModel model)
{
throw new NotImplementedException();
}
public BuildViewModel? Insert(BuildBindingModel model)
{
throw new NotImplementedException();
}
public BuildViewModel? Update(BuildBindingModel model)
{
throw new NotImplementedException();
}
public BuildViewModel? Delete(BuildBindingModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,39 @@
using HardwareShopContracts.BindingModels;
using HardwareShopContracts.SearchModels;
using HardwareShopContracts.ViewModels;
namespace HardwareShopContracts.StoragesContracts
{
public class CommentStorage : ICommentStorage
{
public List<CommentViewModel> GetFullList()
{
throw new NotImplementedException();
}
public List<CommentViewModel> GetFilteredList(CommentSearchModel model)
{
throw new NotImplementedException();
}
public CommentViewModel? GetElement(CommentSearchModel model)
{
throw new NotImplementedException();
}
public CommentViewModel? Insert(CommentBindingModel model)
{
throw new NotImplementedException();
}
public CommentViewModel? Update(CommentBindingModel model)
{
throw new NotImplementedException();
}
public CommentViewModel? Delete(CommentBindingModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,39 @@
using HardwareShopContracts.BindingModels;
using HardwareShopContracts.SearchModels;
using HardwareShopContracts.ViewModels;
namespace HardwareShopContracts.StoragesContracts
{
public class PurchaseStorage : IPurchaseStorage
{
public List<PurchaseViewModel> GetFullList()
{
throw new NotImplementedException();
}
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model)
{
throw new NotImplementedException();
}
public PurchaseViewModel? GetElement(PurchaseSearchModel model)
{
throw new NotImplementedException();
}
public PurchaseViewModel? Insert(PurchaseBindingModel model)
{
throw new NotImplementedException();
}
public PurchaseViewModel? Update(PurchaseBindingModel model)
{
throw new NotImplementedException();
}
public PurchaseViewModel? Delete(PurchaseBindingModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,6 +1,5 @@
using HardwareShopDataModels.Enums;
using HardwareShopDataModels.Models;
using HardwareShopDataModels.Models;
using System.ComponentModel;
namespace HardwareShopDatabaseImplement.Models.Storekeeper
{