Компонентам добавил дату

This commit is contained in:
Алексей Тихоненков 2024-05-27 07:26:26 +04:00
parent e5ef078ca2
commit 075d1bc284
9 changed files with 35 additions and 22 deletions

View File

@ -11,5 +11,6 @@ namespace DiningRoomContracts.BindingModels
public string ComponentName { get; set; } = string.Empty;
public ComponentUnit Unit { get; set; } = ComponentUnit.Неизвестна;
public double Cost { get; set; }
}
public DateTime DateComponentCreate { get; set; } = DateTime.Now;
}
}

View File

@ -5,5 +5,6 @@
public int? Id { get; set; }
public int? UserId { get; set; }
public string ComponentName { get; set; }
}
public DateTime DateComponentCreate { get; set; }
}
}

View File

@ -17,5 +17,6 @@ namespace DiningRoomContracts.ViewModels
[DisplayName("Стоимость")]
public double Cost { get; set; }
}
public DateTime DateComponentCreate { get; set; }
}
}

View File

@ -25,5 +25,7 @@ namespace DiningRoomDataModels.Models
/// </summary>
double Cost { get; }
}
DateTime DateComponentCreate { get; }
}
}

View File

@ -128,23 +128,19 @@ namespace DiningRoomDatabaseImplement.Implements
.ThenInclude(pc => pc.Product)
.ToList()
.SelectMany(card => card.Drinks
.SelectMany(d => d.Components))
.SelectMany(dc => dc.Component.ProductComponents
.Select(pc => new ReportComponentByDateViewModel
{
DateCardCreate = dc.Drink.Card.DateCardCreate,
ComponentId = dc.ComponentId,
ComponentName = dc.Component.ComponentName,
ComponentCost = dc.Component.Cost,
ProductId = pc.ProductId,
ProductName = pc.Product.ProductName,
ProductPrice = pc.Product.Cost,
CardId = dc.Drink.CardId,
CardName = dc.Drink.Card.CardName,
}))
.ToList();
.SelectMany(d => d.Components.SelectMany(dc => dc.Component.ProductComponents.Select(pc => new ReportComponentByDateViewModel
{
ComponentId = pc.ComponentId,
ComponentName = dc.Component.ComponentName,
ComponentCost = dc.Component.Cost,
ProductId = pc.ProductId,
ProductName = pc.Product.ProductName,
ProductPrice = pc.Product.Cost,
CardId = card.Id,
CardName = card.CardName,
}))))
.ToList();
}
}
}

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DiningRoomDatabaseImplement.Migrations
{
[DbContext(typeof(DiningRoomDatabase))]
[Migration("20240526174629_InitialCreate")]
[Migration("20240527031110_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
@ -65,6 +65,9 @@ namespace DiningRoomDatabaseImplement.Migrations
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<DateTime>("DateComponentCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("Unit")
.HasColumnType("integer");

View File

@ -57,6 +57,7 @@ namespace DiningRoomDatabaseImplement.Migrations
UserId = table.Column<int>(type: "integer", nullable: false),
ComponentName = table.Column<string>(type: "text", nullable: false),
Unit = table.Column<int>(type: "integer", nullable: false),
DateComponentCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>

View File

@ -62,6 +62,9 @@ namespace DiningRoomDatabaseImplement.Migrations
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<DateTime>("DateComponentCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("Unit")
.HasColumnType("integer");

View File

@ -17,6 +17,8 @@ namespace DiningRoomDatabaseImplement.Models
public string ComponentName { get; private set; } = string.Empty;
[Required]
public ComponentUnit Unit { get; private set; } = ComponentUnit.Неизвестна;
[Required]
public DateTime DateComponentCreate { get; set; }
[Required]
public double Cost { get; private set; }
@ -36,6 +38,7 @@ namespace DiningRoomDatabaseImplement.Models
{
Id = Model.Id,
ComponentName = Model.ComponentName,
DateComponentCreate = Model.DateComponentCreate,
Cost = Model.Cost,
Unit = Model.Unit,
UserId = Model.UserId,
@ -47,6 +50,7 @@ namespace DiningRoomDatabaseImplement.Models
{
Id = Model.Id,
ComponentName = Model.ComponentName,
DateComponentCreate = Model.DateComponentCreate,
Cost = Model.Cost,
Unit = Model.Unit,
UserId = Model.UserId,
@ -67,6 +71,7 @@ namespace DiningRoomDatabaseImplement.Models
{
Id = Id,
ComponentName = ComponentName,
DateComponentCreate = DateComponentCreate,
Cost = Cost,
Unit = Unit,
UserId = UserId,