сборки с продавцами

This commit is contained in:
bekodeg 2024-05-01 12:25:11 +04:00
parent 96c186a590
commit 56b6290c71
3 changed files with 13 additions and 2 deletions

View File

@ -3,6 +3,7 @@
public class BuildSearchModel
{
public int? Id { get; set; }
public int VendorId { get; set; }
public string? Name { get; set; }
}
}

View File

@ -4,7 +4,7 @@
{
public int? Id { get; set; }
public string? Name { get; set; }
public int? VendorId { get; set; }
public int? Build { get; set; }
public int VendorId { get; set; }
public List<int>? Builds { get; set; }
}
}

View File

@ -16,6 +16,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
.Include(b => b.Comments)
.Include(b => b.Components)
.ThenInclude(b => b.Component)
.Include(b => b.Vendor)
.Select(b => b.GetViewModel)
.ToList();
}
@ -28,6 +29,8 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
}
using var context = new ComputerHardwareStoreDBContext();
return context.Builds
.Include(b => b.Vendor)
.Where(b => b.Vendor.Id == model.VendorId )
.Where(b => b.Name.Contains(model.Name))
.Include(b => b.Comments)
.Include(b => b.Components)
@ -44,6 +47,8 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
}
using var context = new ComputerHardwareStoreDBContext();
return context.Builds
.Include(b => b.Vendor)
.Where(b => b.Vendor.Id == model.VendorId)
.Include(b => b.Comments)
.Include(b => b.Components)
.ThenInclude(b => b.Component)
@ -64,6 +69,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
context.Builds.Add(newBuild);
context.SaveChanges();
return context.Builds
.Include(b => b.Vendor)
.Include(b => b.Comments)
.Include(b => b.Components)
.ThenInclude(b => b.Component)
@ -78,6 +84,8 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
.Include(b => b.Comments)
.Include(b => b.Components)
.ThenInclude(b => b.Component)
.Include(b => b.Vendor)
.Where(b => b.Vendor.Id == model.Vendor.Id)
.FirstOrDefault(p => p.Id == model.Id);
if (build == null)
{
@ -94,6 +102,8 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
.Include(b => b.Comments)
.Include(b => b.Components)
.ThenInclude(b => b.Component)
.Include(b => b.Vendor)
.Where(b => b.Vendor.Id == model.Vendor.Id)
.FirstOrDefault(p => p.Id == model.Id);
if (build == null)
{